Skip to content

Commit

Permalink
Add back workaround to avoid confusing mypy.types and types in pyinfo (
Browse files Browse the repository at this point in the history
…#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.
  • Loading branch information
JukkaL authored Jul 18, 2022
1 parent b8bad23 commit 1a1091e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mypy/pyinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
if MYPY:
from typing import List

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


def getsearchdirs():
# type: () -> List[str]
Expand Down

0 comments on commit 1a1091e

Please sign in to comment.