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

Skip to content
Prev Previous commit
Next Next commit
Update tests
  • Loading branch information
JukkaL committed Apr 20, 2026
commit 5838f6b4e4a6b4134bebf7c254de31f1be1633ae
6 changes: 3 additions & 3 deletions test-data/unit/check-final.test
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ class C:
-- Reassignments

[case testFinalReassignModuleVar]
# flags: --allow-redefinition
# flags: --allow-redefinition-old
from typing import Final

x: Final = 1
Expand All @@ -412,7 +412,7 @@ z: Final = 2 # E: Cannot redefine an existing name as final
z = 3 # E: Cannot assign to final name "z"

[case testFinalReassignModuleVar2]
# flags: --allow-redefinition
# flags: --allow-redefinition-old
from typing import Final

x: Final = 1
Expand All @@ -429,7 +429,7 @@ y
y: Final = 3 # E: Cannot redefine an existing name as final

[case testFinalReassignModuleVar3]
# flags: --disallow-redefinition
# flags: --disallow-redefinition-old
from typing import Final

x: Final = 1
Expand Down
10 changes: 5 additions & 5 deletions test-data/unit/check-flags.test
Original file line number Diff line number Diff line change
Expand Up @@ -2626,7 +2626,7 @@ def f() -> None:
reveal_type(x) # N: Revealed type is "builtins.str"

[case testRedefineLocalWithDifferentTypeInline]
# mypy: allow-redefinition
# mypy: allow-redefinition-old
def f() -> None:
x = 0
reveal_type(x) # N: Revealed type is "builtins.int"
Expand All @@ -2649,7 +2649,7 @@ def f() -> None:
reveal_type(x) # N: Revealed type is "builtins.str"
[file mypy.ini]
\[mypy]
allow_redefinition = true
allow_redefinition_old = true

[case testRedefineLocalWithDifferentTypeConfigOld]
# flags: --config-file tmp/mypy.ini
Expand All @@ -2670,7 +2670,7 @@ def f() -> None:
x = '' # E: Incompatible types in assignment (expression has type "str", variable has type "int")
[file mypy.ini]
\[mypy]
disallow_redefinition = true
disallow_redefinition_old = true

[case testRevealSimpleTypes_no_verbose_reveal]
from typing import Generic, TypeVar, Callable
Expand Down Expand Up @@ -2701,7 +2701,7 @@ reveal_type(fx) # N: Revealed type is "def [Ts] (int, *args: *tuple[*Ts, int])
[builtins fixtures/tuple.pyi]

[case testOnlyOneRedefinitionModeAllowed]
# flags: --allow-redefinition --allow-redefinition-new --local-partial-types
# flags: --allow-redefinition --allow-redefinition-old --local-partial-types
x = 1
[out]
main:1: error: --allow-redefinition-old and --allow-redefinition-new should not be used together
main:1: error: --allow-redefinition-old and --allow-redefinition should not be used together
4 changes: 2 additions & 2 deletions test-data/unit/check-incremental.test
Original file line number Diff line number Diff line change
Expand Up @@ -7116,9 +7116,9 @@ from .lib import NT
[out2]

[case testNewRedefineAffectsCache]
# flags: --local-partial-types --allow-redefinition-new
# flags: --local-partial-types --allow-redefinition
# flags2: --local-partial-types
# flags3: --local-partial-types --allow-redefinition-new
# flags3: --local-partial-types --allow-redefinition
x = 0
if int():
x = ""
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-inference.test
Original file line number Diff line number Diff line change
Expand Up @@ -4351,7 +4351,7 @@ def g() -> None:
reveal_type(x) # N: Revealed type is "builtins.int | None"

[case testGlobalVariableNoneInitMultipleFuncsRedefine]
# flags: --allow-redefinition-new --local-partial-types
# flags: --allow-redefinition --local-partial-types

# Widening this is intentionally prohibited (for now).
x = None
Expand Down
6 changes: 3 additions & 3 deletions test-data/unit/check-narrowing.test
Original file line number Diff line number Diff line change
Expand Up @@ -2801,7 +2801,7 @@ while x is not None and b():
[builtins fixtures/primitives.pyi]

[case testAvoidFalseNonOverlappingEqualityCheckInLoop1]
# flags: --allow-redefinition-new --local-partial-types --strict-equality --warn-unreachable
# flags: --allow-redefinition --local-partial-types --strict-equality --warn-unreachable

def f(x: int) -> None:
while True:
Expand All @@ -2813,7 +2813,7 @@ def f(x: int) -> None:
[builtins fixtures/primitives.pyi]

[case testAvoidFalseNonOverlappingEqualityCheckInLoop2]
# flags: --allow-redefinition-new --local-partial-types --strict-equality --warn-unreachable
# flags: --allow-redefinition --local-partial-types --strict-equality --warn-unreachable

class A: ...
class B: ...
Expand Down Expand Up @@ -2870,7 +2870,7 @@ while b():
[builtins fixtures/bool.pyi]

[case testAvoidFalseUnreachableInFinally]
# flags: --allow-redefinition-new --local-partial-types --strict-equality --warn-unreachable
# flags: --allow-redefinition --local-partial-types --strict-equality --warn-unreachable
def f() -> None:
try:
x = 1
Expand Down
6 changes: 3 additions & 3 deletions test-data/unit/check-python310.test
Original file line number Diff line number Diff line change
Expand Up @@ -2979,7 +2979,7 @@ def match_stmt_error5(x: Optional[str]) -> None:
[builtins fixtures/tuple.pyi]

[case testMatchSubjectRedefinition]
# flags: --allow-redefinition --strict-equality --warn-unreachable
# flags: --allow-redefinition-old --strict-equality --warn-unreachable
def transform1(a: str) -> int:
...

Expand Down Expand Up @@ -3510,7 +3510,7 @@ class Two: ...
[builtins fixtures/tuple.pyi]

[case testNewRedefineMatchBasics]
# flags: --allow-redefinition-new --local-partial-types --strict-equality --warn-unreachable
# flags: --allow-redefinition --local-partial-types --strict-equality --warn-unreachable

def f1(x: int | str | list[bytes]) -> None:
match x:
Expand All @@ -3523,7 +3523,7 @@ def f1(x: int | str | list[bytes]) -> None:
reveal_type(y) # N: Revealed type is "builtins.str | builtins.bytes"

[case testNewRedefineLoopWithMatch]
# flags: --allow-redefinition-new --local-partial-types --strict-equality --warn-unreachable
# flags: --allow-redefinition --local-partial-types --strict-equality --warn-unreachable

def f1() -> None:
while True:
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-python311.test
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def loop():
[builtins fixtures/exception.pyi]

[case testRedefineLocalWithinExceptStarTryClauses]
# flags: --allow-redefinition
# flags: --allow-redefinition-old
def fn_str(_: str) -> int: ...
def fn_int(_: int) -> None: ...
def fn_exc(_: Exception) -> str: ...
Expand Down
Loading