Skip to content

Commit 18687bd

Browse files
Merge branch 'master' into fix-isinstance-native-interpreted-subclass
2 parents e47b5f9 + 6424d0b commit 18687bd

360 files changed

Lines changed: 12971 additions & 4121 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/mypy_primer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
persist-credentials: false
4040
- uses: actions/setup-python@v5
4141
with:
42-
python-version: "3.13"
42+
python-version: "3.14"
4343
- name: Install dependencies
4444
run: |
4545
python -m pip install -U pip

.github/workflows/test.yml

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,22 @@ jobs:
3131
include:
3232
# Make sure to run mypyc compiled unit tests for both
3333
# the oldest and newest supported Python versions
34-
- name: Test suite with py39-ubuntu, mypyc-compiled
35-
python: '3.9'
36-
os: ubuntu-24.04-arm
37-
toxenv: py
38-
tox_extra_args: "-n 4"
39-
test_mypyc: true
40-
- name: Test suite with py310-ubuntu
34+
- name: Test suite with py310-ubuntu, mypyc-compiled
4135
python: '3.10'
4236
os: ubuntu-24.04-arm
4337
toxenv: py
4438
tox_extra_args: "-n 4"
39+
test_mypyc: true
4540
- name: Test suite with py311-ubuntu
4641
python: '3.11'
4742
os: ubuntu-24.04-arm
4843
toxenv: py
4944
tox_extra_args: "-n 4"
50-
- name: Test suite with py312-ubuntu, mypyc-compiled
45+
- name: Test suite with py312-ubuntu
5146
python: '3.12'
5247
os: ubuntu-24.04-arm
5348
toxenv: py
5449
tox_extra_args: "-n 4"
55-
test_mypyc: true
5650
- name: Test suite with py313-ubuntu, mypyc-compiled
5751
python: '3.13'
5852
os: ubuntu-24.04-arm
@@ -65,6 +59,12 @@ jobs:
6559
toxenv: py
6660
tox_extra_args: "-n 4"
6761
test_mypyc: true
62+
- name: Test suite with py314t-ubuntu, mypyc-compiled
63+
python: '3.14t'
64+
os: ubuntu-24.04-arm
65+
toxenv: py
66+
tox_extra_args: "-n 4"
67+
test_mypyc: true
6868
- name: Test suite with py314-windows-64
6969
python: '3.14'
7070
os: windows-latest
@@ -101,12 +101,24 @@ jobs:
101101
# tox_extra_args: "-n 4 mypyc/test/test_run.py mypyc/test/test_external.py"
102102
# debug_build: true
103103

104-
- name: Type check our own code (py39-ubuntu)
105-
python: '3.9'
104+
- name: Parallel tests with py314-ubuntu, interpreted
105+
python: '3.14'
106+
os: ubuntu-24.04-arm
107+
toxenv: py
108+
tox_extra_args: "-n 4 --mypy-num-workers=4 mypy/test/testcheck.py"
109+
- name: Parallel tests with py314-ubuntu, mypyc-compiled
110+
python: '3.14'
111+
os: ubuntu-24.04-arm
112+
toxenv: py
113+
tox_extra_args: "-n 4 --mypy-num-workers=4 mypy/test/testcheck.py"
114+
test_mypyc: true
115+
116+
- name: Type check our own code (py310-ubuntu)
117+
python: '3.10'
106118
os: ubuntu-latest
107119
toxenv: type
108-
- name: Type check our own code (py39-windows-64)
109-
python: '3.9'
120+
- name: Type check our own code (py310-windows-64)
121+
python: '3.10'
110122
os: windows-latest
111123
toxenv: type
112124

.github/workflows/test_stubgenc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ jobs:
3232
with:
3333
persist-credentials: false
3434

35-
- name: Setup 🐍 3.9
35+
- name: Setup 🐍 3.10
3636
uses: actions/setup-python@v5
3737
with:
38-
python-version: 3.9
38+
python-version: '3.10'
3939

4040
- name: Test stubgenc
4141
run: misc/test-stubgenc.sh

CHANGELOG.md

Lines changed: 282 additions & 1 deletion
Large diffs are not rendered by default.

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ hash -r # This resets shell PATH cache, not necessary on Windows
5151
```
5252

5353
> **Note**
54-
> You'll need Python 3.9 or higher to install all requirements listed in
54+
> You'll need Python 3.10 or higher to install all requirements listed in
5555
> test-requirements.txt
5656
5757
### Running tests

docs/source/additional_features.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Type annotations can be added as follows:
135135

136136
.. code-block:: python
137137
138-
import attr
138+
import attrs
139139
140140
@attrs.define
141141
class A:

docs/source/command_line.rst

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -537,13 +537,15 @@ potentially problematic or redundant in some way.
537537
print(x + "bad")
538538
539539
To help prevent mypy from generating spurious warnings, the "Statement is
540-
unreachable" warning will be silenced in exactly two cases:
540+
unreachable" warning will be silenced in exactly three cases:
541541

542542
1. When the unreachable statement is a ``raise`` statement, is an
543543
``assert False`` statement, or calls a function that has the :py:data:`~typing.NoReturn`
544544
return type hint. In other words, when the unreachable statement
545545
throws an error or terminates the program in some way.
546-
2. When the unreachable statement was *intentionally* marked as unreachable
546+
2. When the unreachable statement is ``return NotImplemented``. This
547+
is allowed by mypy due to its use in operator overloading.
548+
3. When the unreachable statement was *intentionally* marked as unreachable
547549
using :ref:`version_and_platform_checks`.
548550

549551
.. note::
@@ -958,12 +960,6 @@ in error messages.
958960
useful or they may be overly noisy. If ``N`` is negative, there is
959961
no limit. The default limit is -1.
960962

961-
.. option:: --force-union-syntax
962-
963-
Always use ``Union[]`` and ``Optional[]`` for union types
964-
in error messages (instead of the ``|`` operator),
965-
even on Python 3.10+.
966-
967963

968964
.. _incremental:
969965

docs/source/config_file.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -930,15 +930,6 @@ These options may only be set in the global section (``[mypy]``).
930930

931931
Show absolute paths to files.
932932

933-
.. confval:: force_union_syntax
934-
935-
:type: boolean
936-
:default: False
937-
938-
Always use ``Union[]`` and ``Optional[]`` for union types
939-
in error messages (instead of the ``|`` operator),
940-
even on Python 3.10+.
941-
942933
Incremental mode
943934
****************
944935

docs/source/error_code_list.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,28 @@ You can use :py:class:`~collections.abc.Callable` as the type for callable objec
215215
for x in objs:
216216
f(x)
217217
218+
.. _code-nonetype-type:
219+
220+
Check that NoneType is not used as a type (annotation) [nonetype-type]
221+
----------------------------------------------------------------------
222+
223+
The preferred way to annotate the type of `None` is `None`.
224+
`NoneType` is equivalent, but mypy won't allow it by default.
225+
226+
.. code-block:: python
227+
228+
from types import NoneType
229+
def f(x: None) -> None:
230+
reveal_type(x) # note: Revealed type is "None"
231+
232+
# error: NoneType should not be used as a type, please use None instead [nonetype-type]
233+
def g(x: NoneType) -> None:
234+
reveal_type(x) # note: Revealed type is "None"
235+
236+
# error: NoneType should not be used as a type, please use None instead [nonetype-type]
237+
x1: NoneType = None
238+
x2: None = None # OK
239+
218240
.. _code-metaclass:
219241

220242
Check the validity of a class's metaclass [metaclass]
@@ -1129,6 +1151,25 @@ Warn about cases where a bytes object may be converted to a string in an unexpec
11291151
print(f"The alphabet starts with {b!r}") # The alphabet starts with b'abc'
11301152
print(f"The alphabet starts with {b.decode('utf-8')}") # The alphabet starts with abc
11311153
1154+
.. _code-str-unpack:
1155+
1156+
Check that ``str`` is not unpacked [str-unpack]
1157+
---------------------------------------------------------
1158+
1159+
It can sometimes be surprising that ``str`` is iterable, especially when unpacking
1160+
in an assignment.
1161+
1162+
Example:
1163+
1164+
.. code-block:: python
1165+
1166+
def print_dict(d: dict[str, str]) -> int:
1167+
# We meant to do d.items(), but instead we're unpacking the str keys of d
1168+
1169+
# Error: Unpacking a string is disallowed
1170+
for k, v in d:
1171+
print(k, v)
1172+
11321173
.. _code-overload-overlap:
11331174

11341175
Check that overloaded functions don't overlap [overload-overlap]

docs/source/error_code_list2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Example:
3232
3333
# mypy: disallow-any-generics
3434
35-
# Error: Missing type parameters for generic type "list" [type-arg]
35+
# Error: Missing type arguments for generic type "list" [type-arg]
3636
def remove_dups(items: list) -> list:
3737
...
3838

0 commit comments

Comments
 (0)