Skip to content

Commit 002f77c

Browse files
authored
Remove mention of Python 2 from documentation (#13255)
1 parent 989e407 commit 002f77c

20 files changed

+20
-629
lines changed

docs/source/cheat_sheet.rst

Lines changed: 0 additions & 282 deletions
This file was deleted.

docs/source/class_basics.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,6 @@ function decorator. Example:
244244
x = Animal() # Error: 'Animal' is abstract due to 'eat' and 'can_walk'
245245
y = Cat() # OK
246246
247-
.. note::
248-
249-
In Python 2.7 you have to use :py:func:`@abc.abstractproperty <abc.abstractproperty>` to define
250-
an abstract property.
251-
252247
Note that mypy performs checking for unimplemented abstract methods
253248
even if you omit the :py:class:`~abc.ABCMeta` metaclass. This can be useful if the
254249
metaclass would cause runtime metaclass conflicts.

docs/source/command_line.rst

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -251,23 +251,13 @@ For more information on how to use these flags, see :ref:`version_and_platform_c
251251

252252
This flag will make mypy type check your code as if it were
253253
run under Python version X.Y. Without this option, mypy will default to using
254-
whatever version of Python is running mypy. Note that the :option:`-2` and
255-
:option:`--py2` flags are aliases for :option:`--python-version 2.7 <--python-version>`.
254+
whatever version of Python is running mypy.
256255

257256
This flag will attempt to find a Python executable of the corresponding
258257
version to search for :pep:`561` compliant packages. If you'd like to
259258
disable this, use the :option:`--no-site-packages` flag (see
260259
:ref:`import-discovery` for more details).
261260

262-
.. option:: -2, --py2
263-
264-
Equivalent to running :option:`--python-version 2.7 <--python-version>`.
265-
266-
.. note::
267-
268-
To check Python 2 code with mypy, you'll need to install mypy with
269-
``pip install 'mypy[python2]'``.
270-
271261
.. option:: --platform PLATFORM
272262

273263
This flag will make mypy type check your code as if it were

docs/source/common_issues.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,8 @@ More specifically, mypy will understand the use of :py:data:`sys.version_info` a
441441
# Distinguishing between different versions of Python:
442442
if sys.version_info >= (3, 8):
443443
# Python 3.8+ specific definitions and imports
444-
elif sys.version_info[0] >= 3:
445-
# Python 3 specific definitions and imports
446444
else:
447-
# Python 2 specific definitions and imports
445+
# Other definitions and imports
448446
449447
# Distinguishing between different operating systems:
450448
if sys.platform.startswith("linux"):
@@ -484,9 +482,9 @@ operating system as default values for :py:data:`sys.version_info` and
484482
:py:data:`sys.platform`.
485483

486484
To target a different Python version, use the :option:`--python-version X.Y <mypy --python-version>` flag.
487-
For example, to verify your code typechecks if were run using Python 2, pass
488-
in :option:`--python-version 2.7 <mypy --python-version>` from the command line. Note that you do not need
489-
to have Python 2.7 installed to perform this check.
485+
For example, to verify your code typechecks if were run using Python 3.8, pass
486+
in :option:`--python-version 3.8 <mypy --python-version>` from the command line. Note that you do not need
487+
to have Python 3.8 installed to perform this check.
490488

491489
To target a different operating system, use the :option:`--platform PLATFORM <mypy --platform>` flag.
492490
For example, to verify your code typechecks if it were run in Windows, pass

docs/source/config_file.rst

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ of your repo and run mypy.
114114
# Global options:
115115
116116
[mypy]
117-
python_version = 2.7
118117
warn_return_any = True
119118
warn_unused_configs = True
120119
@@ -129,16 +128,13 @@ of your repo and run mypy.
129128
[mypy-somelibrary]
130129
ignore_missing_imports = True
131130
132-
This config file specifies three global options in the ``[mypy]`` section. These three
131+
This config file specifies two global options in the ``[mypy]`` section. These two
133132
options will:
134133

135-
1. Type-check your entire project assuming it will be run using Python 2.7.
136-
(This is equivalent to using the :option:`--python-version 2.7 <mypy --python-version>` or :option:`-2 <mypy -2>` flag).
137-
138-
2. Report an error whenever a function returns a value that is inferred
134+
1. Report an error whenever a function returns a value that is inferred
139135
to have type ``Any``.
140136

141-
3. Report any config options that are unused by mypy. (This will help us catch typos
137+
2. Report any config options that are unused by mypy. (This will help us catch typos
142138
when making changes to our config file).
143139

144140
Next, this module specifies three per-module options. The first two options change how mypy

docs/source/duck_type_compatibility.rst

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ supported for a small set of built-in types:
99
* ``int`` is duck type compatible with ``float`` and ``complex``.
1010
* ``float`` is duck type compatible with ``complex``.
1111
* ``bytearray`` and ``memoryview`` are duck type compatible with ``bytes``.
12-
* In Python 2, ``str`` is duck type compatible with ``unicode``.
1312

1413
For example, mypy considers an ``int`` object to be valid whenever a
1514
``float`` object is expected. Thus code like this is nice and clean
@@ -30,16 +29,3 @@ a more principled and extensible fashion. Protocols don't apply to
3029
cases like ``int`` being compatible with ``float``, since ``float`` is not
3130
a protocol class but a regular, concrete class, and many standard library
3231
functions expect concrete instances of ``float`` (or ``int``).
33-
34-
.. note::
35-
36-
Note that in Python 2 a ``str`` object with non-ASCII characters is
37-
often *not valid* when a unicode string is expected. The mypy type
38-
system does not consider a string with non-ASCII values as a
39-
separate type so some programs with this kind of error will
40-
silently pass type checking. In Python 3 ``str`` and ``bytes`` are
41-
separate, unrelated types and this kind of error is easy to
42-
detect. This a good reason for preferring Python 3 over Python 2!
43-
44-
See :ref:`text-and-anystr` for details on how to enforce that a
45-
value must be a unicode string in a cross-compatible way.

0 commit comments

Comments
 (0)