Skip to content
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

Drop Python 3.5 support #10706

Merged
merged 1 commit into from
Jun 24, 2021
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
1 change: 0 additions & 1 deletion build-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
-r mypy-requirements.txt
types-typed-ast>=1.4.0,<1.5.0
types-toml>=0.0
types-enum34>=0.0; python_version == '3.5'
6 changes: 0 additions & 6 deletions docs/source/class_basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,6 @@ particular attribute should not be set on instances:
a.x = 1 # Error: Cannot assign to class variable "x" via instance
print(a.x) # OK -- can be read through an instance

.. note::

If you need to support Python 3 versions 3.5.2 or earlier, you have
to import ``ClassVar`` from ``typing_extensions`` instead (available on
PyPI). If you use Python 2.7, you can import it from ``typing``.

It's not necessary to annotate all class variables using
:py:data:`~typing.ClassVar`. An attribute without the :py:data:`~typing.ClassVar` annotation can
still be used as a class variable. However, mypy won't prevent it from
Expand Down
6 changes: 3 additions & 3 deletions docs/source/common_issues.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Can't install mypy using pip

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

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

Expand Down Expand Up @@ -428,8 +428,8 @@ More specifically, mypy will understand the use of :py:data:`sys.version_info` a
import sys

# Distinguishing between different versions of Python:
if sys.version_info >= (3, 5):
# Python 3.5+ specific definitions and imports
if sys.version_info >= (3, 8):
# Python 3.8+ specific definitions and imports
elif sys.version_info[0] >= 3:
# Python 3 specific definitions and imports
else:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ may not make much sense otherwise.
Installing and running mypy
***************************

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

Expand Down
6 changes: 0 additions & 6 deletions docs/source/runtime_troubles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,6 @@ Since code inside ``if TYPE_CHECKING:`` is not executed at runtime, it provides
a convenient way to tell mypy something without the code being evaluated at
runtime. This is most useful for resolving :ref:`import cycles <import-cycles>`.

.. note::

Python 3.5.1 and below don't have :py:data:`~typing.TYPE_CHECKING`. An
alternative is to define a constant named ``MYPY`` that has the value
``False`` at runtime. Mypy considers it to be ``True`` when type checking.

Class name forward references
-----------------------------

Expand Down
2 changes: 1 addition & 1 deletion mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ def _load_json_file(file: str, manager: BuildManager,
manager.trace(log_success + data.rstrip())
try:
result = json.loads(data)
except ValueError: # TODO: JSONDecodeError in 3.5
except json.JSONDecodeError:
manager.errors.set_file(file, None)
manager.errors.report(-1, -1,
"Error reading JSON file;"
Expand Down
2 changes: 1 addition & 1 deletion mypy/fastparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,7 @@ def translate_expr_list(self, l: Sequence[ast3.expr]) -> List[Type]:

def visit_raw_str(self, s: str) -> Type:
# An escape hatch that allows the AST walker in fastparse2 to
# directly hook into the Python 3.5 type converter in some cases
# directly hook into the Python 3 type converter in some cases
# without needing to create an intermediary `Str` object.
_, typ = parse_type_comment(s.strip(),
self.line,
Expand Down
4 changes: 2 additions & 2 deletions mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ class PythonExecutableInferenceError(Exception):
def python_executable_prefix(v: str) -> List[str]:
if sys.platform == 'win32':
# on Windows, all Python executables are named `python`. To handle this, there
# is the `py` launcher, which can be passed a version e.g. `py -3.5`, and it will
# execute an installed Python 3.5 interpreter. See also:
# is the `py` launcher, which can be passed a version e.g. `py -3.8`, and it will
# execute an installed Python 3.8 interpreter. See also:
# https://docs.python.org/3/using/windows.html#python-launcher-for-windows
return ['py', '-{}'.format(v)]
else:
Expand Down
14 changes: 2 additions & 12 deletions mypy/stubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,7 @@ def __repr__(self) -> str:
MISSING = Missing()

T = TypeVar("T")
if sys.version_info >= (3, 5, 3):
MaybeMissing = Union[T, Missing]
else:
# work around a bug in 3.5.2 and earlier's typing.py
class MaybeMissingMeta(type):
def __getitem__(self, arg: Any) -> Any:
return Union[arg, Missing]

class MaybeMissing(metaclass=MaybeMissingMeta): # type: ignore
pass

MaybeMissing = Union[T, Missing]

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

Expand Down Expand Up @@ -1069,7 +1059,7 @@ def get_typeshed_stdlib_modules(custom_typeshed_dir: Optional[str]) -> List[str]
"""Returns a list of stdlib modules in typeshed (for current Python version)."""
stdlib_py_versions = mypy.modulefinder.load_stdlib_py_versions(custom_typeshed_dir)
packages = set()
# Typeshed doesn't cover Python 3.5.
# Typeshed's minimum supported Python 3 is Python 3.6
if sys.version_info < (3, 6):
version_info = (3, 6)
else:
Expand Down
10 changes: 3 additions & 7 deletions mypy/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,9 @@ def get_unique_redefinition_name(name: str, existing: Container[str]) -> str:
def check_python_version(program: str) -> None:
"""Report issues with the Python used to run mypy, dmypy, or stubgen"""
# Check for known bad Python versions.
if sys.version_info[:2] < (3, 5):
sys.exit("Running {name} with Python 3.4 or lower is not supported; "
"please upgrade to 3.5 or newer".format(name=program))
# this can be deleted once we drop support for 3.5
if sys.version_info[:3] == (3, 5, 0):
sys.exit("Running {name} with Python 3.5.0 is not supported; "
"please upgrade to 3.5.1 or newer".format(name=program))
if sys.version_info[:2] < (3, 6):
sys.exit("Running {name} with Python 3.5 or lower is not supported; "
"please upgrade to 3.6 or newer".format(name=program))


def count_stats(errors: List[str]) -> Tuple[int, int]:
Expand Down
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import os.path
import sys

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

# we'll import stuff from the source tree, let's ensure is on the sys path
Expand Down Expand Up @@ -162,7 +162,6 @@ def run(self):
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
Expand Down Expand Up @@ -198,7 +197,7 @@ def run(self):
],
# Same here.
extras_require={'dmypy': 'psutil >= 4.0', 'python2': 'typed_ast >= 1.4.0, < 1.5.0'},
python_requires=">=3.5",
python_requires=">=3.6",
include_package_data=True,
project_urls={
'News': 'http://mypy-lang.org/news.html',
Expand Down
3 changes: 1 addition & 2 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ flake8-bugbear; python_version >= '3.5'
flake8-pyi>=20.5; python_version >= '3.6'
lxml>=4.4.0
psutil>=4.0
# pytest 6.2 does not support Python 3.5
pytest>=6.1.0,<6.2.0
pytest>=6.2.0,<7.0.0
pytest-xdist>=1.34.0,<2.0.0
pytest-forked>=1.3.0,<2.0.0
pytest-cov>=2.10.0,<3.0.0
Expand Down