Skip to content

Commit 336d9f7

Browse files
Merge branch 'master' into reverse_op_for_subclass
2 parents cf95330 + 8241059 commit 336d9f7

File tree

88 files changed

+2088
-714
lines changed

Some content is hidden

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

88 files changed

+2088
-714
lines changed

.github/workflows/mypy_primer.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ jobs:
6767
--debug \
6868
--additional-flags="--debug-serialize" \
6969
--output concise \
70-
--show-speed-regression \
7170
| tee diff_${{ matrix.shard-index }}.txt
7271
) || [ $? -eq 1 ]
7372
- if: ${{ matrix.shard-index == 0 }}

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,33 @@
22

33
## Next Release
44

5+
### Remove Support for targeting Python 3.8
6+
7+
Mypy now requires `--python-version 3.9` or greater. Support for only Python 3.8 is
8+
fully removed now. Given an unsupported version, mypy will default to the oldest
9+
supported one, currently 3.9.
10+
11+
This change is necessary because typeshed stopped supporting Python 3.8 after it
12+
reached its End of Life in October 2024.
13+
14+
Contributed by Marc Mueller
15+
(PR [19157](https://github.com/python/mypy/pull/19157), PR [19162](https://github.com/python/mypy/pull/19162)).
16+
17+
### Initial Support for Python 3.14
18+
19+
Mypy is now tested on 3.14 and mypyc works with 3.14.0b3 and later.
20+
Mypyc compiled wheels of mypy itself will be available for new versions after 3.14.0rc1 is released.
21+
22+
Note that not all new features might be supported just yet.
23+
24+
Contributed by Marc Mueller (PR [19164](https://github.com/python/mypy/pull/19164))
25+
26+
### Deprecated Flag: \--force-uppercase-builtins
27+
28+
Mypy only supports Python 3.9+. The \--force-uppercase-builtins flag is now deprecated and a no-op. It will be removed in a future version.
29+
30+
Contributed by Marc Mueller (PR [19176](https://github.com/python/mypy/pull/19176))
31+
532
## Mypy 1.16
633

734
We’ve just uploaded mypy 1.16 to the Python Package Index ([PyPI](https://pypi.org/project/mypy/)).

docs/source/command_line.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,7 @@ of the above sections.
845845
x = 'a string'
846846
x.trim() # error: "str" has no attribute "trim" [attr-defined]
847847
848+
848849
.. _configuring-error-messages:
849850

850851
Configuring error messages
@@ -936,11 +937,6 @@ in error messages.
936937
useful or they may be overly noisy. If ``N`` is negative, there is
937938
no limit. The default limit is -1.
938939

939-
.. option:: --force-uppercase-builtins
940-
941-
Always use ``List`` instead of ``list`` in error messages,
942-
even on Python 3.9+.
943-
944940
.. option:: --force-union-syntax
945941

946942
Always use ``Union[]`` and ``Optional[]`` for union types

docs/source/config_file.rst

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

923923
Show absolute paths to files.
924924

925-
.. confval:: force_uppercase_builtins
926-
927-
:type: boolean
928-
:default: False
929-
930-
Always use ``List`` instead of ``list`` in error messages,
931-
even on Python 3.9+.
932-
933925
.. confval:: force_union_syntax
934926

935927
:type: boolean

docs/source/error_code_list2.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,3 +612,44 @@ Example:
612612
# mypy: disallow-any-explicit
613613
from typing import Any
614614
x: Any = 1 # Error: Explicit "Any" type annotation [explicit-any]
615+
616+
617+
.. _code-exhaustive-match:
618+
619+
Check that match statements match exhaustively [exhaustive-match]
620+
-----------------------------------------------------------------------
621+
622+
If enabled with :option:`--enable-error-code exhaustive-match <mypy --enable-error-code>`,
623+
mypy generates an error if a match statement does not match all possible cases/types.
624+
625+
626+
Example:
627+
628+
.. code-block:: python
629+
630+
import enum
631+
632+
633+
class Color(enum.Enum):
634+
RED = 1
635+
BLUE = 2
636+
637+
val: Color = Color.RED
638+
639+
# OK without --enable-error-code exhaustive-match
640+
match val:
641+
case Color.RED:
642+
print("red")
643+
644+
# With --enable-error-code exhaustive-match
645+
# Error: Match statement has unhandled case for values of type "Literal[Color.BLUE]"
646+
match val:
647+
case Color.RED:
648+
print("red")
649+
650+
# OK with or without --enable-error-code exhaustive-match, since all cases are handled
651+
match val:
652+
case Color.RED:
653+
print("red")
654+
case _:
655+
print("other")

docs/source/literal_types.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,10 @@ If we forget to handle one of the cases, mypy will generate an error:
468468
assert_never(direction) # E: Argument 1 to "assert_never" has incompatible type "Direction"; expected "NoReturn"
469469
470470
Exhaustiveness checking is also supported for match statements (Python 3.10 and later).
471+
For match statements specifically, inexhaustive matches can be caught
472+
without needing to use ``assert_never`` by using
473+
:option:`--enable-error-code exhaustive-match <mypy --enable-error-code>`.
474+
471475

472476
Extra Enum checks
473477
*****************

misc/self_compile_info.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"""Print list of files compiled when compiling self (mypy and mypyc)."""
2+
3+
import argparse
4+
import sys
5+
from typing import Any
6+
7+
import setuptools
8+
9+
import mypyc.build
10+
11+
12+
class FakeExtension:
13+
def __init__(self, *args: Any, **kwargs: Any) -> None:
14+
pass
15+
16+
17+
def fake_mypycify(args: list[str], **kwargs: Any) -> list[FakeExtension]:
18+
for target in sorted(args):
19+
if not target.startswith("-"):
20+
print(target)
21+
return [FakeExtension()]
22+
23+
24+
def fake_setup(*args: Any, **kwargs: Any) -> Any:
25+
pass
26+
27+
28+
def main() -> None:
29+
parser = argparse.ArgumentParser(
30+
description="Print list of files compiled when compiling self. Run in repository root."
31+
)
32+
parser.parse_args()
33+
34+
# Prepare fake state for running setup.py.
35+
mypyc.build.mypycify = fake_mypycify # type: ignore[assignment]
36+
setuptools.Extension = FakeExtension # type: ignore[misc, assignment]
37+
setuptools.setup = fake_setup
38+
sys.argv = [sys.argv[0], "--use-mypyc"]
39+
40+
# Run setup.py at the root of the repository.
41+
import setup # noqa: F401
42+
43+
44+
if __name__ == "__main__":
45+
main()

0 commit comments

Comments
 (0)