Skip to content

Remove python2 from build.py and reachability.py #13280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2547,18 +2547,7 @@ def find_module_and_diagnose(

Returns a tuple containing (file path, target's effective follow_imports setting)
"""
file_id = id
if id == "builtins" and options.python_version[0] == 2:
# The __builtin__ module is called internally by mypy
# 'builtins' in Python 2 mode (similar to Python 3),
# but the stub file is __builtin__.pyi. The reason is
# that a lot of code hard-codes 'builtins.x' and it's
# easier to work it around like this. It also means
# that the implementation can mostly ignore the
# difference and just assume 'builtins' everywhere,
# which simplifies code.
file_id = "__builtin__"
result = find_module_with_reason(file_id, manager)
result = find_module_with_reason(id, manager)
if isinstance(result, str):
# For non-stubs, look at options.follow_imports:
# - normal (default) -> fully analyze
Expand Down Expand Up @@ -2614,7 +2603,7 @@ def find_module_and_diagnose(
# search path or the module has not been installed.

ignore_missing_imports = options.ignore_missing_imports
top_level, second_level = get_top_two_prefixes(file_id)
top_level, second_level = get_top_two_prefixes(id)
# Don't honor a global (not per-module) ignore_missing_imports
# setting for modules that used to have bundled stubs, as
# otherwise updating mypy can silently result in new false
Expand Down
4 changes: 2 additions & 2 deletions mypy/reachability.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ def infer_condition_value(expr: Expression, options: Options) -> int:
result = consider_sys_platform(expr, options.platform)
if result == TRUTH_VALUE_UNKNOWN:
if name == "PY2":
result = ALWAYS_TRUE if pyversion[0] == 2 else ALWAYS_FALSE
result = ALWAYS_FALSE
elif name == "PY3":
result = ALWAYS_TRUE if pyversion[0] == 3 else ALWAYS_FALSE
result = ALWAYS_TRUE
elif name == "MYPY" or name == "TYPE_CHECKING":
result = MYPY_TRUE
elif name in options.always_true:
Expand Down