diff options
author | Ran Benita <ran@unusedvar.com> | 2020-08-03 19:15:21 +0300 |
---|---|---|
committer | Ran Benita <ran@unusedvar.com> | 2020-08-04 09:59:46 +0300 |
commit | 9ab14c6d9cc8318f62d14e0c49ca37a13972bd0e (patch) | |
tree | 2f8d1153454591e2e5d284d92b5bb996a00f488d /src/_pytest/compat.py | |
parent | 0dd5e169d0cfab2bee64fb6f463449d9347c489a (diff) | |
download | pytest-9ab14c6d9cc8318f62d14e0c49ca37a13972bd0e.tar.gz |
typing: set warn_unreachable
This makes mypy raise an error whenever it detects code which is
statically unreachable, e.g.
x: int
if isinstance(x, str):
... # Statement is unreachable [unreachable]
This is really neat and finds quite a few logic and typing bugs.
Sometimes the code is intentionally unreachable in terms of types, e.g.
raising TypeError when a function is given an argument with a wrong
type. In these cases a `type: ignore[unreachable]` is needed, but I
think it's a nice code hint.
Diffstat (limited to 'src/_pytest/compat.py')
-rw-r--r-- | src/_pytest/compat.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index 93232f1bf..ff98492dc 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -176,8 +176,9 @@ def getfuncargnames( p.name for p in parameters.values() if ( - p.kind is Parameter.POSITIONAL_OR_KEYWORD - or p.kind is Parameter.KEYWORD_ONLY + # TODO: Remove type ignore after https://github.com/python/typeshed/pull/4383 + p.kind is Parameter.POSITIONAL_OR_KEYWORD # type: ignore[unreachable] + or p.kind is Parameter.KEYWORD_ONLY # type: ignore[unreachable] ) and p.default is Parameter.empty ) |