summaryrefslogtreecommitdiff
path: root/src/_pytest/compat.py
diff options
context:
space:
mode:
authorDaniel Hahler <git@thequod.de>2020-01-10 19:53:57 +0100
committerDaniel Hahler <git@thequod.de>2020-01-16 16:11:39 +0100
commit4630e2725e84bb07fc0527c2c293b500dfe585a6 (patch)
tree33f3a916afda932befcf28fba5ce61e909d83017 /src/_pytest/compat.py
parent715f56dfbc432fbf99b8ad668e86a5063de58250 (diff)
downloadpytest-4630e2725e84bb07fc0527c2c293b500dfe585a6.tar.gz
Use `TYPE_CHECKING` instead of `False`
This allows for e.g. Jedi to infer types (it checks the name). It was only used to support Python 3.5.0/3.5.1, where this is is not available in the `typing` module. Ref: https://github.com/davidhalter/jedi/issues/1472 Uses `TYPE_CHECKING = False` in `_pytest.outcomes` to avoid having to work around circular import.
Diffstat (limited to 'src/_pytest/compat.py')
-rw-r--r--src/_pytest/compat.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py
index de640bdd1..cc5140b0c 100644
--- a/src/_pytest/compat.py
+++ b/src/_pytest/compat.py
@@ -27,7 +27,13 @@ from _pytest._io.saferepr import saferepr
from _pytest.outcomes import fail
from _pytest.outcomes import TEST_OUTCOME
-if False: # TYPE_CHECKING
+if sys.version_info < (3, 5, 2):
+ TYPE_CHECKING = False # type: bool
+else:
+ from typing import TYPE_CHECKING
+
+
+if TYPE_CHECKING:
from typing import Type # noqa: F401 (used in type string)