Skip to content

Commit 61c0064

Browse files
committed
Add back workaround to avoid confusing mypy.types and types in pyinfo (#13176)
We run mypy/pyinfo.py as a script, and this means that mypy/types.py could be picked up instead of the stdlib `types` module, which clearly doesn't work. This seems to happen at least on macOS, and it broke PEP 561 tests. The workaround was accidentally removed as part of #13161. This should fix #13174 and help with the wheel builds.
1 parent d8d900c commit 61c0064

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

mypy/pyinfo.py

+9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@
1414
if MYPY:
1515
from typing import List
1616

17+
if __name__ == '__main__':
18+
# HACK: We don't want to pick up mypy.types as the top-level types
19+
# module. This could happen if this file is run as a script.
20+
# This workaround fixes it.
21+
old_sys_path = sys.path
22+
sys.path = sys.path[1:]
23+
import types # noqa
24+
sys.path = old_sys_path
25+
1726

1827
def getsearchdirs():
1928
# type: () -> List[str]

0 commit comments

Comments
 (0)