@@ -551,7 +551,7 @@ potentially problematic or redundant in some way.
551551 .. note ::
552552
553553 Mypy currently cannot detect and report unreachable or redundant code
554- inside any functions using :ref: `type-variable-value-restriction `.
554+ inside any functions using :ref: `value-constrained type variables < value-constrained-type-variables > `.
555555
556556 This limitation will be removed in future releases of mypy.
557557
@@ -595,13 +595,13 @@ of the above sections.
595595 This flag causes mypy to suppress errors caused by not being able to fully
596596 infer the types of global and class variables.
597597
598- .. option :: --allow-redefinition-new
598+ .. option :: --allow-redefinition
599599
600600 By default, mypy won't allow a variable to be redefined with an
601- unrelated type. This flag enables the redefinition of unannotated
602- variables with an arbitrary type. You will also need to enable
603- :option: `--local-partial-types <mypy --local-partial-types> `.
604- Example:
601+ unrelated type. This flag enables the redefinition of * unannotated *
602+ variables with an arbitrary type. This also requires
603+ :option: `--local-partial-types <mypy --no- local-partial-types> `, which is
604+ enabled by default starting from mypy 2.0. Example:
605605
606606 .. code-block :: python
607607
@@ -613,7 +613,7 @@ of the above sections.
613613 # Type of "x" is "int | str" here.
614614 return x
615615
616- Without the new flag, mypy only supports inferring optional types
616+ Without this flag, mypy only supports inferring optional types
617617 (``X | None ``) from multiple assignments. With this option enabled,
618618 mypy can infer arbitrary union types.
619619
@@ -644,27 +644,23 @@ of the above sections.
644644 reveal_type(values) # Revealed type is list[float]
645645
646646 Note: We are planning to turn this flag on by default in a future mypy
647- release, along with :option: `--local-partial-types <mypy --local-partial-types> `.
648- The feature is still experimental, and the semantics may still change.
647+ release.
649648
650- .. option :: --allow-redefinition
649+ .. option :: --allow-redefinition-new
651650
652- This is an alias to :option: `--allow-redefinition-old <mypy --allow-redefinition-old> `.
653- In mypy v2.0 this will point to
654- :option: `--allow-redefinition-new <mypy --allow-redefinition-new> `, and will
655- eventually became the default.
651+ Deprecated alias for :option: `--allow-redefinition <mypy --allow-redefinition> `.
656652
657653.. option :: --allow-redefinition-old
658654
659- This is an older variant of
660- :option: `--allow-redefinition-new <mypy --allow-redefinition-new > `.
655+ This is an older, more limited variant of
656+ :option: `--allow-redefinition <mypy --allow-redefinition> `.
661657 This flag enables redefinition of a variable with an
662658 arbitrary type *in some contexts *: only redefinitions within the
663659 same block and nesting depth as the original definition are allowed.
664660
665- We have no plans to remove this flag, but we expect that
666- :option: `--allow-redefinition-new <mypy --allow-redefinition-new > `
667- will replace this flag for new use cases eventually .
661+ We have no plans to remove this flag, but
662+ :option: `--allow-redefinition <mypy --allow-redefinition> `
663+ is recommended for new use cases.
668664
669665 Example where this can be useful:
670666
@@ -685,30 +681,26 @@ of the above sections.
685681 items = " 100" # valid, items now has type str
686682 items = int (items) # valid, items now has type int
687683
688- .. option :: --local-partial-types
684+ .. option :: --no- local-partial-types
689685
690- In mypy, the most common cases for partial types are variables initialized using ``None ``,
691- but without explicit ``X | None `` annotations. By default, mypy won't check partial types
692- spanning module top level or class top level. This flag changes the behavior to only allow
693- partial types at local level, therefore it disallows inferring variable type for ``None ``
694- from two assignments in different scopes. For example:
686+ Disable local partial types to enable legacy type inference mode for
687+ containers.
695688
696- .. code-block :: python
689+ Local partial types prevent inferring a container type for a variable, when
690+ the initial assignment happens at module top level or in a class body, and
691+ the container item type is only set in a function. Example:
697692
698- a = None # Need type annotation here if using --local-partial-types
699- b: int | None = None
693+ .. code-block :: python
700694
701- class Foo :
702- bar = None # Need type annotation here if using --local-partial-types
703- baz: int | None = None
695+ a = [] # Need type annotation unless using --no-local-partial-types
704696
705- def __init__ ( self ) -> None :
706- self .bar = 1
697+ def func ( ) -> None :
698+ a.append( 1 )
707699
708- reveal_type(Foo().bar) # ' int | None' without - -local-partial-types
700+ reveal_type(a) # "list[ int]" if using --no -local-partial-types
709701
710- Note: this option is always implicitly enabled in mypy daemon and will become
711- enabled by default in mypy v2.0 release .
702+ Local partial types are enabled by default starting from mypy 2.0. The
703+ mypy daemon requires local partial types .
712704
713705.. option :: --no-implicit-reexport
714706
@@ -765,11 +757,11 @@ of the above sections.
765757 Note that :option: `--strict-equality-for-none <mypy --strict-equality-for-none> `
766758 only works in combination with :option: `--strict-equality <mypy --strict-equality> `.
767759
768- .. option :: --strict-bytes
760+ .. option :: --no- strict-bytes
769761
770- By default, mypy treats ``bytearray `` and ``memoryview `` as subtypes of ``bytes `` which
771- is not true at runtime. Use this flag to disable this behavior. `` --strict-bytes `` will
772- be enabled by default in * mypy 2.0 * .
762+ Treat ``bytearray `` and ``memoryview `` as subtypes of ``bytes ``. This is not true
763+ at runtime and can lead to unexpected behavior. This was the default behavior prior
764+ to mypy 2.0.
773765
774766 .. code-block :: python
775767
@@ -778,10 +770,12 @@ of the above sections.
778770 with open (" binary_file" , " wb" ) as fp:
779771 fp.write(buf)
780772
781- f(bytearray (b " " )) # error: Argument 1 to "f" has incompatible type "bytearray"; expected "bytes"
782- f(memoryview (b " " )) # error: Argument 1 to "f" has incompatible type "memoryview"; expected "bytes"
773+ # Using --no-strict-bytes disables the following errors
774+ f(bytearray (b " " )) # Argument 1 to "f" has incompatible type "bytearray"; expected "bytes"
775+ f(memoryview (b " " )) # Argument 1 to "f" has incompatible type "memoryview"; expected "bytes"
783776
784- # If `f` accepts any object that implements the buffer protocol, consider using:
777+ # If `f` accepts any object that implements the buffer protocol,
778+ # consider using Buffer instead:
785779 from collections.abc import Buffer # "from typing_extensions" in Python 3.11 and earlier
786780
787781 def f (buf : Buffer) -> None :
@@ -1019,9 +1013,10 @@ beyond what incremental mode can offer, try running mypy in
10191013 writing to the cache, use ``--cache-dir=/dev/null `` (UNIX)
10201014 or ``--cache-dir=nul `` (Windows).
10211015
1022- .. option :: --sqlite-cache
1016+ .. option :: --no- sqlite-cache
10231017
1024- Use an `SQLite `_ database to store the cache.
1018+ Avoid using `SQLite `_ database to store the cache, instead write cache data
1019+ out to individual files.
10251020
10261021.. option :: --cache-fine-grained
10271022
0 commit comments