Skip to content

Commit 379622d

Browse files
authored
Drop Python 3.5 support (#10706)
1 parent 48181d2 commit 379622d

12 files changed

+17
-46
lines changed

build-requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
-r mypy-requirements.txt
22
types-typed-ast>=1.4.0,<1.5.0
33
types-toml>=0.0
4-
types-enum34>=0.0; python_version == '3.5'

docs/source/class_basics.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,6 @@ particular attribute should not be set on instances:
127127
a.x = 1 # Error: Cannot assign to class variable "x" via instance
128128
print(a.x) # OK -- can be read through an instance
129129
130-
.. note::
131-
132-
If you need to support Python 3 versions 3.5.2 or earlier, you have
133-
to import ``ClassVar`` from ``typing_extensions`` instead (available on
134-
PyPI). If you use Python 2.7, you can import it from ``typing``.
135-
136130
It's not necessary to annotate all class variables using
137131
:py:data:`~typing.ClassVar`. An attribute without the :py:data:`~typing.ClassVar` annotation can
138132
still be used as a class variable. However, mypy won't prevent it from

docs/source/common_issues.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Can't install mypy using pip
1414

1515
If installation fails, you've probably hit one of these issues:
1616

17-
* Mypy needs Python 3.5 or later to run.
17+
* Mypy needs Python 3.6 or later to run.
1818
* You may have to run pip like this:
1919
``python3 -m pip install mypy``.
2020

@@ -428,8 +428,8 @@ More specifically, mypy will understand the use of :py:data:`sys.version_info` a
428428
import sys
429429
430430
# Distinguishing between different versions of Python:
431-
if sys.version_info >= (3, 5):
432-
# Python 3.5+ specific definitions and imports
431+
if sys.version_info >= (3, 8):
432+
# Python 3.8+ specific definitions and imports
433433
elif sys.version_info[0] >= 3:
434434
# Python 3 specific definitions and imports
435435
else:

docs/source/getting_started.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ may not make much sense otherwise.
1212
Installing and running mypy
1313
***************************
1414

15-
Mypy requires Python 3.5 or later to run. Once you've
15+
Mypy requires Python 3.6 or later to run. Once you've
1616
`installed Python 3 <https://www.python.org/downloads/>`_,
1717
install mypy using pip:
1818

docs/source/runtime_troubles.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,6 @@ Since code inside ``if TYPE_CHECKING:`` is not executed at runtime, it provides
9494
a convenient way to tell mypy something without the code being evaluated at
9595
runtime. This is most useful for resolving :ref:`import cycles <import-cycles>`.
9696

97-
.. note::
98-
99-
Python 3.5.1 and below don't have :py:data:`~typing.TYPE_CHECKING`. An
100-
alternative is to define a constant named ``MYPY`` that has the value
101-
``False`` at runtime. Mypy considers it to be ``True`` when type checking.
102-
10397
Class name forward references
10498
-----------------------------
10599

mypy/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ def _load_json_file(file: str, manager: BuildManager,
10911091
manager.trace(log_success + data.rstrip())
10921092
try:
10931093
result = json.loads(data)
1094-
except ValueError: # TODO: JSONDecodeError in 3.5
1094+
except json.JSONDecodeError:
10951095
manager.errors.set_file(file, None)
10961096
manager.errors.report(-1, -1,
10971097
"Error reading JSON file;"

mypy/fastparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,7 @@ def translate_expr_list(self, l: Sequence[ast3.expr]) -> List[Type]:
13571357

13581358
def visit_raw_str(self, s: str) -> Type:
13591359
# An escape hatch that allows the AST walker in fastparse2 to
1360-
# directly hook into the Python 3.5 type converter in some cases
1360+
# directly hook into the Python 3 type converter in some cases
13611361
# without needing to create an intermediary `Str` object.
13621362
_, typ = parse_type_comment(s.strip(),
13631363
self.line,

mypy/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ class PythonExecutableInferenceError(Exception):
237237
def python_executable_prefix(v: str) -> List[str]:
238238
if sys.platform == 'win32':
239239
# on Windows, all Python executables are named `python`. To handle this, there
240-
# is the `py` launcher, which can be passed a version e.g. `py -3.5`, and it will
241-
# execute an installed Python 3.5 interpreter. See also:
240+
# is the `py` launcher, which can be passed a version e.g. `py -3.8`, and it will
241+
# execute an installed Python 3.8 interpreter. See also:
242242
# https://docs.python.org/3/using/windows.html#python-launcher-for-windows
243243
return ['py', '-{}'.format(v)]
244244
else:

mypy/stubtest.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,7 @@ def __repr__(self) -> str:
3838
MISSING = Missing()
3939

4040
T = TypeVar("T")
41-
if sys.version_info >= (3, 5, 3):
42-
MaybeMissing = Union[T, Missing]
43-
else:
44-
# work around a bug in 3.5.2 and earlier's typing.py
45-
class MaybeMissingMeta(type):
46-
def __getitem__(self, arg: Any) -> Any:
47-
return Union[arg, Missing]
48-
49-
class MaybeMissing(metaclass=MaybeMissingMeta): # type: ignore
50-
pass
51-
41+
MaybeMissing = Union[T, Missing]
5242

5343
_formatter = FancyFormatter(sys.stdout, sys.stderr, False)
5444

@@ -1069,7 +1059,7 @@ def get_typeshed_stdlib_modules(custom_typeshed_dir: Optional[str]) -> List[str]
10691059
"""Returns a list of stdlib modules in typeshed (for current Python version)."""
10701060
stdlib_py_versions = mypy.modulefinder.load_stdlib_py_versions(custom_typeshed_dir)
10711061
packages = set()
1072-
# Typeshed doesn't cover Python 3.5.
1062+
# Typeshed's minimum supported Python 3 is Python 3.6
10731063
if sys.version_info < (3, 6):
10741064
version_info = (3, 6)
10751065
else:

mypy/util.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -393,13 +393,9 @@ def get_unique_redefinition_name(name: str, existing: Container[str]) -> str:
393393
def check_python_version(program: str) -> None:
394394
"""Report issues with the Python used to run mypy, dmypy, or stubgen"""
395395
# Check for known bad Python versions.
396-
if sys.version_info[:2] < (3, 5):
397-
sys.exit("Running {name} with Python 3.4 or lower is not supported; "
398-
"please upgrade to 3.5 or newer".format(name=program))
399-
# this can be deleted once we drop support for 3.5
400-
if sys.version_info[:3] == (3, 5, 0):
401-
sys.exit("Running {name} with Python 3.5.0 is not supported; "
402-
"please upgrade to 3.5.1 or newer".format(name=program))
396+
if sys.version_info[:2] < (3, 6):
397+
sys.exit("Running {name} with Python 3.5 or lower is not supported; "
398+
"please upgrade to 3.6 or newer".format(name=program))
403399

404400

405401
def count_stats(errors: List[str]) -> Tuple[int, int]:

setup.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import os.path
66
import sys
77

8-
if sys.version_info < (3, 5, 0):
9-
sys.stderr.write("ERROR: You need Python 3.5 or later to use mypy.\n")
8+
if sys.version_info < (3, 6, 0):
9+
sys.stderr.write("ERROR: You need Python 3.6 or later to use mypy.\n")
1010
exit(1)
1111

1212
# we'll import stuff from the source tree, let's ensure is on the sys path
@@ -162,7 +162,6 @@ def run(self):
162162
'Intended Audience :: Developers',
163163
'License :: OSI Approved :: MIT License',
164164
'Programming Language :: Python :: 3',
165-
'Programming Language :: Python :: 3.5',
166165
'Programming Language :: Python :: 3.6',
167166
'Programming Language :: Python :: 3.7',
168167
'Programming Language :: Python :: 3.8',
@@ -198,7 +197,7 @@ def run(self):
198197
],
199198
# Same here.
200199
extras_require={'dmypy': 'psutil >= 4.0', 'python2': 'typed_ast >= 1.4.0, < 1.5.0'},
201-
python_requires=">=3.5",
200+
python_requires=">=3.6",
202201
include_package_data=True,
203202
project_urls={
204203
'News': 'http://mypy-lang.org/news.html',

test-requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ flake8-bugbear; python_version >= '3.5'
66
flake8-pyi>=20.5; python_version >= '3.6'
77
lxml>=4.4.0
88
psutil>=4.0
9-
# pytest 6.2 does not support Python 3.5
10-
pytest>=6.1.0,<6.2.0
9+
pytest>=6.2.0,<7.0.0
1110
pytest-xdist>=1.34.0,<2.0.0
1211
pytest-forked>=1.3.0,<2.0.0
1312
pytest-cov>=2.10.0,<3.0.0

0 commit comments

Comments
 (0)