Skip to content

Commit

Permalink
Typeshed minimal version is 3.7 (#13348)
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn authored Aug 8, 2022
1 parent 49e3386 commit 45b9f51
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
1 change: 0 additions & 1 deletion mypy-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
typing_extensions>=3.10
mypy_extensions>=0.4.3
importlib_resources; python_version<'3.7'
typed_ast>=1.4.0,<2; python_version<'3.8'
tomli>=1.1.0; python_version<'3.11'
4 changes: 2 additions & 2 deletions mypy/modulefinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,6 @@ def parse_version(version: str) -> Tuple[int, int]:

def typeshed_py_version(options: Options) -> Tuple[int, int]:
"""Return Python version used for checking whether module supports typeshed."""
# Typeshed no longer covers Python 3.x versions before 3.6, so 3.6 is
# Typeshed no longer covers Python 3.x versions before 3.7, so 3.7 is
# the earliest we can support.
return max(options.python_version, (3, 6))
return max(options.python_version, (3, 7))
6 changes: 3 additions & 3 deletions mypy/stubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1454,9 +1454,9 @@ def get_typeshed_stdlib_modules(
stdlib_py_versions = mypy.modulefinder.load_stdlib_py_versions(custom_typeshed_dir)
if version_info is None:
version_info = sys.version_info[0:2]
# Typeshed's minimum supported Python 3 is Python 3.6
if sys.version_info < (3, 6):
version_info = (3, 6)
# Typeshed's minimum supported Python 3 is Python 3.7
if sys.version_info < (3, 7):
version_info = (3, 7)

def exists_in_version(module: str) -> bool:
assert version_info is not None
Expand Down
3 changes: 2 additions & 1 deletion mypy/test/teststubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1412,13 +1412,14 @@ def test_only_py(self) -> None:
assert output_str == "Success: no issues found in 1 module\n"

def test_get_typeshed_stdlib_modules(self) -> None:
stdlib = mypy.stubtest.get_typeshed_stdlib_modules(None, (3, 6))
stdlib = mypy.stubtest.get_typeshed_stdlib_modules(None, (3, 7))
assert "builtins" in stdlib
assert "os" in stdlib
assert "os.path" in stdlib
assert "asyncio" in stdlib
assert "graphlib" not in stdlib
assert "formatter" in stdlib
assert "contextvars" in stdlib # 3.7+
assert "importlib.metadata" not in stdlib

stdlib = mypy.stubtest.get_typeshed_stdlib_modules(None, (3, 10))
Expand Down
7 changes: 1 addition & 6 deletions mypy/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@
import shutil
import sys
import time

try:
from importlib import resources as importlib_resources # type: ignore[attr-defined]
except ImportError: # <python3.7
import importlib_resources # type: ignore

from importlib import resources as importlib_resources
from typing import (
IO,
Callable,
Expand Down

0 comments on commit 45b9f51

Please sign in to comment.