Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Prev Previous commit
Next Next commit
Doc updates
  • Loading branch information
JukkaL committed Apr 20, 2026
commit b79d8ecd4da5b57c0c53fc9fa5f0ff7e5d47f626
17 changes: 7 additions & 10 deletions docs/source/command_line.rst
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ of the above sections.
This flag causes mypy to suppress errors caused by not being able to fully
infer the types of global and class variables.

.. option:: --allow-redefinition-new
.. option:: --allow-redefinition

By default, mypy won't allow a variable to be redefined with an
unrelated type. This flag enables the redefinition of *unannotated*
Expand All @@ -613,7 +613,7 @@ of the above sections.
# Type of "x" is "int | str" here.
return x

Without the new flag, mypy only supports inferring optional types
Without this flag, mypy only supports inferring optional types
(``X | None``) from multiple assignments. With this option enabled,
mypy can infer arbitrary union types.

Expand Down Expand Up @@ -646,23 +646,20 @@ of the above sections.
Note: We are planning to turn this flag on by default in a future mypy
release.

.. option:: --allow-redefinition
.. option:: --allow-redefinition-new

This is an alias to :option:`--allow-redefinition-old <mypy --allow-redefinition-old>`.
In mypy v2.0 this will point to
:option:`--allow-redefinition-new <mypy --allow-redefinition-new>`, and will
eventually became the default.
Deprecated alias for :option:`--allow-redefinition <mypy --allow-redefinition>`.

.. option:: --allow-redefinition-old

This is an older variant of
:option:`--allow-redefinition-new <mypy --allow-redefinition-new>`.
This is an older, more limited variant of
:option:`--allow-redefinition <mypy --allow-redefinition>`.
This flag enables redefinition of a variable with an
arbitrary type *in some contexts*: only redefinitions within the
same block and nesting depth as the original definition are allowed.

We have no plans to remove this flag, but we expect that
:option:`--allow-redefinition-new <mypy --allow-redefinition-new>`
:option:`--allow-redefinition <mypy --allow-redefinition>`
will replace this flag for new use cases eventually.

Example where this can be useful:
Expand Down
17 changes: 8 additions & 9 deletions docs/source/config_file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ section of the command line docs.
Causes mypy to suppress errors caused by not being able to fully
infer the types of global and class variables.

.. confval:: allow_redefinition_new
.. confval:: allow_redefinition

:type: boolean
:default: False
Expand Down Expand Up @@ -763,6 +763,13 @@ section of the command line docs.
Note: We are planning to turn this flag on by default in a future mypy
release.

.. confval:: allow_redefinition_new

:type: boolean
:default: False

Deprecated alias for :confval:`allow_redefinition`.

.. confval:: allow_redefinition_old

:type: boolean
Expand All @@ -789,14 +796,6 @@ section of the command line docs.
items = "100" # valid, items now has type str
items = int(items) # valid, items now has type int

.. confval:: allow_redefinition

:type: boolean
:default: False

An alias to :confval:`allow_redefinition_old`, in mypy v2.0 this will point to
:confval:`allow_redefinition_new`, and will eventually became the default.

.. confval:: local_partial_types

:type: boolean
Expand Down