22
33## Next Release
44
5- ### Planned Changes to Defaults in Mypy 2.0
5+ ### Planned Changes to Defaults and Flags in Mypy 2.0
66
77As a reminder, we are planning to enable ` --local-partial-types ` by default in mypy 2.0, which
88will likely be the next feature release. This will often require at least minor code changes. This
@@ -26,10 +26,11 @@ minor code changes to adopt. For more information, refer to the
2626[ documentation] ( https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-strict-bytes ) .
2727
2828Finally, ` --allow-redefinition-new ` will be renamed to ` --allow-redefinition ` . If you want
29- to continue using the older ` --allow-redefinition ` semantics, you can switch to
30- ` --allow-redefinition-old ` , which is now supported as an alias to ` --allow-redefinition ` .
31- To use ` --allow-redefinition-old ` in the upcoming mypy 2.0, you will also have to use
32- ` --no-local-partial-types ` . For more information, refer to the
29+ to continue using the older ` --allow-redefinition ` semantics which are less flexible (e.g.
30+ limited support for conditional redefinitions), you can switch to ` --allow-redefinition-old ` ,
31+ which is currently supported as an alias to the legacy ` --allow-redefinition ` behavior.
32+ To use ` --allow-redefinition ` in the upcoming mypy 2.0, you can't use ` --no-local-partial-types ` .
33+ For more information, refer to the
3334[ documentation] ( https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-allow-redefinition-new ) .
3435
3536### Better Type Narrowing
@@ -124,10 +125,6 @@ Compatibility between mypy's default behavior and the `--local-partial-types` fl
124125is now improved. This improves compatibility between mypy daemon and non-daemon modes,
125126since the mypy daemon requires local partial types to be enabled.
126127
127- Also, we are planning to turn local partial types on by default in mypy 2.0 (to be
128- released soon), and this makes the change much less disruptive. However, explicitly
129- disabling local partial types will continue to be supported indefinitely.
130-
131128In particular, code like this now behaves consistently independent of
132129whether local partial types are enabled or not:
133130
@@ -141,6 +138,13 @@ def foo() -> None:
141138# The inferred type of 'x' is always 'int | None'.
142139```
143140
141+ Also, we are planning to turn local partial types on by default in mypy 2.0 (to be
142+ released soon), and this makes the change much less disruptive. Explicitly disabling local
143+ partial types will continue to be supported, but the support will likely be
144+ deprecated and removed eventually, as the legacy behavior is hard to support together with
145+ some important changes we are working on, in addition to being incompatible with the mypy
146+ daemon.
147+
144148This feature was contributed by Ivan Levkivskyi (PR [ 20938] ( https://github.com/python/mypy/pull/20938 ) ).
145149
146150### Python 3.14 T-String Support (PEP 750)
0 commit comments