File tree 18 files changed +44
-17
lines changed 18 files changed +44
-17
lines changed Original file line number Diff line number Diff line change @@ -24,3 +24,5 @@ exclude_lines =
24
24
\# \s*pragma: no cover
25
25
^\s*raise NotImplementedError\b
26
26
^\s*return NotImplemented\b
27
+
28
+ ^\s*if TYPE_CHECKING:
Original file line number Diff line number Diff line change
1
+ Added ``typing_extensions `` as dependency on Python 3.5.1 or lower.
Original file line number Diff line number Diff line change 19
19
import sys
20
20
21
21
from _pytest import __version__ as version
22
+ from _pytest .compat import TYPE_CHECKING
22
23
23
- if False : # TYPE_CHECKING
24
+ if TYPE_CHECKING :
24
25
import sphinx .application
25
26
26
27
Original file line number Diff line number Diff line change 32
32
from _pytest ._io .saferepr import safeformat
33
33
from _pytest ._io .saferepr import saferepr
34
34
from _pytest .compat import overload
35
+ from _pytest .compat import TYPE_CHECKING
35
36
36
- if False : # TYPE_CHECKING
37
+ if TYPE_CHECKING :
37
38
from typing import Type
38
39
from typing_extensions import Literal
39
40
from weakref import ReferenceType # noqa: F401
Original file line number Diff line number Diff line change 1
1
"""
2
2
python version compatibility code
3
3
"""
4
+ import sys # isort:skip
5
+
6
+ if sys .version_info < (3 , 5 , 2 ):
7
+ TYPE_CHECKING = False # type: bool
8
+ else :
9
+ from typing import TYPE_CHECKING
10
+
4
11
import functools
5
12
import inspect
6
13
import io
7
14
import os
8
15
import re
9
- import sys
10
16
from contextlib import contextmanager
11
17
from inspect import Parameter
12
18
from inspect import signature
28
34
from _pytest .outcomes import fail
29
35
from _pytest .outcomes import TEST_OUTCOME
30
36
31
- if False : # TYPE_CHECKING
37
+
38
+ if TYPE_CHECKING :
32
39
from typing import Type # noqa: F401 (used in type string)
33
40
34
41
Original file line number Diff line number Diff line change 37
37
from _pytest ._code import ExceptionInfo
38
38
from _pytest ._code import filter_traceback
39
39
from _pytest .compat import importlib_metadata
40
+ from _pytest .compat import TYPE_CHECKING
40
41
from _pytest .outcomes import fail
41
42
from _pytest .outcomes import Skipped
42
43
from _pytest .pathlib import Path
43
44
from _pytest .warning_types import PytestConfigWarning
44
45
45
- if False : # TYPE_CHECKING
46
+ if TYPE_CHECKING :
46
47
from typing import Type
47
48
48
49
from .argparsing import Argument
Original file line number Diff line number Diff line change 15
15
16
16
import py
17
17
18
+ from _pytest .compat import TYPE_CHECKING
18
19
from _pytest .config .exceptions import UsageError
19
20
20
- if False : # TYPE_CHECKING
21
+ if TYPE_CHECKING :
21
22
from typing import NoReturn
22
23
from typing_extensions import Literal # noqa: F401
23
24
Original file line number Diff line number Diff line change 5
5
import py
6
6
7
7
from .exceptions import UsageError
8
+ from _pytest .compat import TYPE_CHECKING
8
9
from _pytest .outcomes import fail
9
10
10
- if False :
11
+ if TYPE_CHECKING :
11
12
from . import Config # noqa: F401
12
13
13
14
Original file line number Diff line number Diff line change 19
19
from _pytest ._code .code import ReprFileLocation
20
20
from _pytest ._code .code import TerminalRepr
21
21
from _pytest .compat import safe_getattr
22
+ from _pytest .compat import TYPE_CHECKING
22
23
from _pytest .fixtures import FixtureRequest
23
24
from _pytest .outcomes import Skipped
24
25
from _pytest .python_api import approx
25
26
from _pytest .warning_types import PytestWarning
26
27
27
- if False : # TYPE_CHECKING
28
+ if TYPE_CHECKING :
28
29
import doctest
29
30
from typing import Type
30
31
Original file line number Diff line number Diff line change 27
27
from _pytest .compat import is_generator
28
28
from _pytest .compat import NOTSET
29
29
from _pytest .compat import safe_getattr
30
+ from _pytest .compat import TYPE_CHECKING
30
31
from _pytest .deprecated import FIXTURE_POSITIONAL_ARGUMENTS
31
32
from _pytest .deprecated import FUNCARGNAMES
32
33
from _pytest .outcomes import fail
33
34
from _pytest .outcomes import TEST_OUTCOME
34
35
35
- if False : # TYPE_CHECKING
36
+ if TYPE_CHECKING :
36
37
from typing import Type
37
38
38
39
from _pytest import nodes
Original file line number Diff line number Diff line change 17
17
from _pytest ._code .code import ReprExceptionInfo
18
18
from _pytest .compat import cached_property
19
19
from _pytest .compat import getfslineno
20
+ from _pytest .compat import TYPE_CHECKING
20
21
from _pytest .config import Config
21
22
from _pytest .deprecated import NODE_USE_FROM_PARENT
22
23
from _pytest .fixtures import FixtureDef
27
28
from _pytest .mark .structures import NodeKeywords
28
29
from _pytest .outcomes import Failed
29
30
30
- if False : # TYPE_CHECKING
31
+ if TYPE_CHECKING :
31
32
# Imported here due to circular import.
32
33
from _pytest .main import Session # noqa: F401
33
34
Original file line number Diff line number Diff line change 8
8
9
9
from packaging .version import Version
10
10
11
- if False : # TYPE_CHECKING
11
+ from _pytest .compat import TYPE_CHECKING
12
+
13
+ if TYPE_CHECKING :
12
14
from typing import NoReturn
13
15
14
16
Original file line number Diff line number Diff line change 28
28
from _pytest ._io .saferepr import saferepr
29
29
from _pytest .capture import MultiCapture
30
30
from _pytest .capture import SysCapture
31
+ from _pytest .compat import TYPE_CHECKING
31
32
from _pytest .fixtures import FixtureRequest
32
33
from _pytest .main import ExitCode
33
34
from _pytest .main import Session
34
35
from _pytest .monkeypatch import MonkeyPatch
35
36
from _pytest .pathlib import Path
36
37
from _pytest .reports import TestReport
37
38
38
- if False : # TYPE_CHECKING
39
+ if TYPE_CHECKING :
39
40
from typing import Type
40
41
41
42
@@ -189,7 +190,7 @@ def __repr__(self):
189
190
del d ["_name" ]
190
191
return "<ParsedCall {!r}(**{!r})>" .format (self ._name , d )
191
192
192
- if False : # TYPE_CHECKING
193
+ if TYPE_CHECKING :
193
194
# The class has undetermined attributes, this tells mypy about it.
194
195
def __getattr__ (self , key ):
195
196
raise NotImplementedError ()
Original file line number Diff line number Diff line change 23
23
import _pytest ._code
24
24
from _pytest .compat import overload
25
25
from _pytest .compat import STRING_TYPES
26
+ from _pytest .compat import TYPE_CHECKING
26
27
from _pytest .outcomes import fail
27
28
28
- if False : # TYPE_CHECKING
29
+ if TYPE_CHECKING :
29
30
from typing import Type # noqa: F401 (used in type string)
30
31
31
32
Original file line number Diff line number Diff line change 12
12
from typing import Union
13
13
14
14
from _pytest .compat import overload
15
+ from _pytest .compat import TYPE_CHECKING
15
16
from _pytest .fixtures import yield_fixture
16
17
from _pytest .outcomes import fail
17
18
18
- if False : # TYPE_CHECKING
19
+ if TYPE_CHECKING :
19
20
from typing import Type
20
21
21
22
Original file line number Diff line number Diff line change 15
15
from .reports import CollectReport
16
16
from .reports import TestReport
17
17
from _pytest ._code .code import ExceptionInfo
18
+ from _pytest .compat import TYPE_CHECKING
18
19
from _pytest .nodes import Node
19
20
from _pytest .outcomes import Exit
20
21
from _pytest .outcomes import Skipped
21
22
from _pytest .outcomes import TEST_OUTCOME
22
23
23
- if False : # TYPE_CHECKING
24
+ if TYPE_CHECKING :
24
25
from typing import Type
25
26
26
27
#
Original file line number Diff line number Diff line change 4
4
5
5
import attr
6
6
7
+ from _pytest .compat import TYPE_CHECKING
7
8
8
- if False : # TYPE_CHECKING
9
+ if TYPE_CHECKING :
9
10
from typing import Type # noqa: F401 (used in type string)
10
11
11
12
Original file line number Diff line number Diff line change @@ -182,6 +182,8 @@ markers =
182
182
[flake8]
183
183
max-line-length = 120
184
184
extend-ignore = E203
185
+ per-file-ignores =
186
+ src/_pytest/compat.py: E402
185
187
186
188
[isort]
187
189
; This config mimics what reorder-python-imports does.
You can’t perform that action at this time.
0 commit comments