Skip to content

Commit 2448cec

Browse files
committed
Don't use TYPE_CHECKING (because it isn't in 3.5.1), use MYPY instead
1 parent e9ee27f commit 2448cec

File tree

6 files changed

+19
-15
lines changed

6 files changed

+19
-15
lines changed

mypy/build.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
from os.path import dirname, basename
2222

2323
from typing import (AbstractSet, Dict, Iterable, Iterator, List,
24-
NamedTuple, Optional, Set, Tuple, Union, TYPE_CHECKING)
24+
NamedTuple, Optional, Set, Tuple, Union)
2525
# Can't use TYPE_CHECKING because it's not in the Python 3.5.1 stdlib
2626
MYPY = False
2727
if MYPY:
2828
from typing import Deque
29+
from mypy.options import Options
2930

3031
from mypy.nodes import (MypyFile, Node, ImportBase, Import, ImportFrom, ImportAll)
3132
from mypy.semanal import FirstPass, SemanticAnalyzer, ThirdPass
@@ -42,9 +43,6 @@
4243
from mypy.types import Type
4344
from mypy.version import __version__
4445

45-
if TYPE_CHECKING:
46-
from mypy.options import Options
47-
4846
# We need to know the location of this file to load data, but
4947
# until Python 3.4, __file__ is relative.
5048
__file__ = os.path.realpath(__file__)

mypy/checker.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
import sys
77

88
from typing import (
9-
Dict, Set, List, cast, Tuple, TypeVar, Union, Optional, NamedTuple, Iterator,
10-
TYPE_CHECKING
9+
Dict, Set, List, cast, Tuple, TypeVar, Union, Optional, NamedTuple, Iterator
1110
)
1211

1312
from mypy.errors import Errors, report_internal_error
@@ -59,7 +58,7 @@
5958

6059
from mypy import experiments
6160

62-
if TYPE_CHECKING:
61+
if MYPY:
6362
from mypy.options import Options
6463

6564
T = TypeVar('T')

mypy/errors.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
from collections import OrderedDict, defaultdict
55
from contextlib import contextmanager
66

7-
from typing import Tuple, List, TypeVar, Set, Dict, Iterator, Optional, TYPE_CHECKING
7+
from typing import Tuple, List, TypeVar, Set, Dict, Iterator, Optional
88

99
from mypy.version import __version__ as mypy_version
1010

11-
if TYPE_CHECKING:
11+
# Can't use TYPE_CHECKING because it's not in the Python 3.5.1 stdlib
12+
MYPY = False
13+
if MYPY:
1214
from mypy.options import Options
1315

1416
T = TypeVar('T')

mypy/parse.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
from typing import List, Tuple, Set, cast, Union, Optional, TYPE_CHECKING
1+
from typing import List, Tuple, Set, cast, Union, Optional
22

33
from mypy.errors import Errors
44
from mypy.nodes import MypyFile
55

6-
if TYPE_CHECKING:
6+
# Can't use TYPE_CHECKING because it's not in the Python 3.5.1 stdlib
7+
MYPY = False
8+
if MYPY:
79
from mypy.options import Options
810

911

mypy/report.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import tokenize
99
from operator import attrgetter
1010

11-
from typing import Any, Callable, Dict, List, Optional, Tuple, cast, TYPE_CHECKING
11+
from typing import Any, Callable, Dict, List, Optional, Tuple, cast
1212

1313
import time
1414

@@ -20,7 +20,9 @@
2020
from mypy.types import Type
2121
from mypy.version import __version__
2222

23-
if TYPE_CHECKING:
23+
# Can't use TYPE_CHECKING because it's not in the Python 3.5.1 stdlib
24+
MYPY = False
25+
if MYPY:
2426
from mypy.options import Options
2527

2628
try:

mypy/semanal.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848

4949
from typing import (
5050
List, Dict, Set, Tuple, cast, TypeVar, Union, Optional, Callable, Iterator,
51-
TYPE_CHECKING
5251
)
5352

5453
from mypy.nodes import (
@@ -92,7 +91,9 @@
9291
from mypy.sametypes import is_same_type
9392
from mypy import join
9493

95-
if TYPE_CHECKING:
94+
# Can't use TYPE_CHECKING because it's not in the Python 3.5.1 stdlib
95+
MYPY = False
96+
if MYPY:
9697
from mypy.options import Options
9798

9899
T = TypeVar('T')

0 commit comments

Comments
 (0)