Skip to content

Commit 17fbde1

Browse files
authored
Remove some hacks around using @overload (#7436)
1 parent 162df36 commit 17fbde1

File tree

2 files changed

+2
-25
lines changed

2 files changed

+2
-25
lines changed

mypy/fastparse.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import (
66
Tuple, Union, TypeVar, Callable, Sequence, Optional, Any, Dict, cast, List, overload
77
)
8-
from typing_extensions import Final, Literal
8+
from typing_extensions import Final, Literal, overload
99

1010
from mypy.sharedparse import (
1111
special_function_elide_names, argument_elide_name,
@@ -127,18 +127,6 @@ def ast3_parse(source: Union[str, bytes], filename: str, mode: str,
127127
TYPE_IGNORE_PATTERN = re.compile(r'[^#]*#\s*type:\s*ignore\s*(\[[^[#]*\]\s*)?($|#)')
128128

129129

130-
# Older versions of typing don't allow using overload outside stubs,
131-
# so provide a dummy.
132-
# mypyc doesn't like function declarations nested in if statements
133-
def _overload(x: Any) -> Any:
134-
return x
135-
136-
137-
# mypyc doesn't like unreachable code, so trick mypy into thinking the branch is reachable
138-
if bool() or sys.version_info < (3, 6):
139-
overload = _overload # noqa
140-
141-
142130
def parse(source: Union[str, bytes],
143131
fnam: str,
144132
module: Optional[str],

mypy/types.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Any, TypeVar, Dict, List, Tuple, cast, Set, Optional, Union, Iterable, NamedTuple,
99
Sequence, Iterator, overload
1010
)
11-
from typing_extensions import ClassVar, Final, TYPE_CHECKING
11+
from typing_extensions import ClassVar, Final, TYPE_CHECKING, overload
1212

1313
import mypy.nodes
1414
from mypy import state
@@ -21,17 +21,6 @@
2121
from mypy.bogus_type import Bogus
2222

2323

24-
# Older versions of typing don't allow using overload outside stubs,
25-
# so provide a dummy.
26-
# mypyc doesn't like function declarations nested in if statements
27-
def _overload(x: Any) -> Any:
28-
return x
29-
30-
31-
# mypyc doesn't like unreachable code, so trick mypy into thinking the branch is reachable
32-
if bool() or sys.version_info < (3, 6):
33-
overload = _overload # noqa
34-
3524
T = TypeVar('T')
3625

3726
JsonDict = Dict[str, Any]

0 commit comments

Comments
 (0)