Skip to content

Commit 5b03024

Browse files
authored
Remove --new-type-inference flag (#19570)
It was on deprecated almost two years ago (it is on by default).
1 parent 0c922ce commit 5b03024

11 files changed

+6
-75
lines changed

mypy/main.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,10 +1086,6 @@ def add_invertible_flag(
10861086
internals_group.add_argument(
10871087
"--old-type-inference", action="store_true", help=argparse.SUPPRESS
10881088
)
1089-
# Deprecated reverse variant of the above.
1090-
internals_group.add_argument(
1091-
"--new-type-inference", action="store_true", help=argparse.SUPPRESS
1092-
)
10931089
internals_group.add_argument(
10941090
"--disable-expression-cache", action="store_true", help=argparse.SUPPRESS
10951091
)
@@ -1507,12 +1503,6 @@ def set_strict_flags() -> None:
15071503
if options.logical_deps:
15081504
options.cache_fine_grained = True
15091505

1510-
if options.new_type_inference:
1511-
print(
1512-
"Warning: --new-type-inference flag is deprecated;"
1513-
" new type inference algorithm is already enabled by default"
1514-
)
1515-
15161506
if options.strict_concatenate and not strict_option_set:
15171507
print("Warning: --strict-concatenate is deprecated; use --extra-checks instead")
15181508

mypy/options.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,8 @@ def __init__(self) -> None:
391391
# skip most errors after this many messages have been reported.
392392
# -1 means unlimited.
393393
self.many_errors_threshold = defaults.MANY_ERRORS_THRESHOLD
394-
# Disable new experimental type inference algorithm.
394+
# Disable new type inference algorithm.
395395
self.old_type_inference = False
396-
# Deprecated reverse version of the above, do not use.
397-
self.new_type_inference = False
398396
# Disable expression cache (for debugging).
399397
self.disable_expression_cache = False
400398
# Export line-level, limited, fine-grained dependency information in cache data

test-data/unit/check-generics.test

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2750,7 +2750,6 @@ reveal_type(func(1)) # N: Revealed type is "builtins.int"
27502750
[builtins fixtures/tuple.pyi]
27512751

27522752
[case testGenericLambdaGenericMethodNoCrash]
2753-
# flags: --new-type-inference
27542753
from typing import TypeVar, Union, Callable, Generic
27552754

27562755
S = TypeVar("S")
@@ -2789,7 +2788,6 @@ reveal_type(dict2) # N: Revealed type is "builtins.dict[Any, __main__.B]"
27892788
-- ------------------------------------------------------------------
27902789

27912790
[case testInferenceAgainstGenericCallable]
2792-
# flags: --new-type-inference
27932791
from typing import TypeVar, Callable, List
27942792

27952793
X = TypeVar('X')
@@ -2807,7 +2805,6 @@ reveal_type(bar(id)) # N: Revealed type is "builtins.list[builtins.int]"
28072805
[builtins fixtures/list.pyi]
28082806

28092807
[case testInferenceAgainstGenericCallableNoLeak]
2810-
# flags: --new-type-inference
28112808
from typing import TypeVar, Callable
28122809

28132810
T = TypeVar('T')
@@ -2823,7 +2820,6 @@ reveal_type(f(tpl)) # N: Revealed type is "Any"
28232820
[out]
28242821

28252822
[case testInferenceAgainstGenericCallableChain]
2826-
# flags: --new-type-inference
28272823
from typing import TypeVar, Callable, List
28282824

28292825
X = TypeVar('X')
@@ -2836,7 +2832,6 @@ reveal_type(chain(id, id)) # N: Revealed type is "def (builtins.int) -> builtin
28362832
[builtins fixtures/list.pyi]
28372833

28382834
[case testInferenceAgainstGenericCallableGeneric]
2839-
# flags: --new-type-inference
28402835
from typing import TypeVar, Callable, List
28412836

28422837
S = TypeVar('S')
@@ -2857,7 +2852,6 @@ reveal_type(same(42)) # N: Revealed type is "builtins.list[builtins.int]"
28572852
[builtins fixtures/list.pyi]
28582853

28592854
[case testInferenceAgainstGenericCallableGenericReverse]
2860-
# flags: --new-type-inference
28612855
from typing import TypeVar, Callable, List
28622856

28632857
S = TypeVar('S')
@@ -2878,7 +2872,6 @@ reveal_type(same([42])) # N: Revealed type is "builtins.int"
28782872
[builtins fixtures/list.pyi]
28792873

28802874
[case testInferenceAgainstGenericCallableGenericArg]
2881-
# flags: --new-type-inference
28822875
from typing import TypeVar, Callable, List
28832876

28842877
S = TypeVar('S')
@@ -2899,7 +2892,6 @@ reveal_type(single(42)) # N: Revealed type is "builtins.list[builtins.int]"
28992892
[builtins fixtures/list.pyi]
29002893

29012894
[case testInferenceAgainstGenericCallableGenericChain]
2902-
# flags: --new-type-inference
29032895
from typing import TypeVar, Callable, List
29042896

29052897
S = TypeVar('S')
@@ -2913,7 +2905,6 @@ reveal_type(comb(id, id)) # N: Revealed type is "def [T] (T`1) -> T`1"
29132905
[builtins fixtures/list.pyi]
29142906

29152907
[case testInferenceAgainstGenericCallableGenericNonLinear]
2916-
# flags: --new-type-inference
29172908
from typing import TypeVar, Callable, List
29182909

29192910
S = TypeVar('S')
@@ -2934,7 +2925,6 @@ reveal_type(mix([id, id, id])) # N: Revealed type is "def [S] (S`4) -> builtins
29342925
[builtins fixtures/list.pyi]
29352926

29362927
[case testInferenceAgainstGenericCurry]
2937-
# flags: --new-type-inference
29382928
from typing import Callable, List, TypeVar
29392929

29402930
S = TypeVar("S")
@@ -2953,7 +2943,6 @@ reveal_type(dec2(test2)) # N: Revealed type is "def [T] (T`3) -> def (T`3) -> T
29532943
[builtins fixtures/list.pyi]
29542944

29552945
[case testInferenceAgainstGenericCallableNewVariable]
2956-
# flags: --new-type-inference
29572946
from typing import TypeVar, Callable, List
29582947

29592948
S = TypeVar('S')
@@ -2968,7 +2957,6 @@ reveal_type(dec(test)) # N: Revealed type is "def [U] (builtins.list[U`-1]) ->
29682957
[builtins fixtures/list.pyi]
29692958

29702959
[case testInferenceAgainstGenericCallableGenericAlias]
2971-
# flags: --new-type-inference
29722960
from typing import TypeVar, Callable, List
29732961

29742962
S = TypeVar('S')
@@ -2986,7 +2974,6 @@ reveal_type(dec(id)) # N: Revealed type is "def [S] (S`1) -> builtins.list[S`1]
29862974
[builtins fixtures/list.pyi]
29872975

29882976
[case testInferenceAgainstGenericCallableGenericProtocol]
2989-
# flags: --new-type-inference
29902977
from typing import TypeVar, Protocol, Generic, Optional
29912978

29922979
T = TypeVar('T')
@@ -3002,7 +2989,6 @@ reveal_type(lift(g)) # N: Revealed type is "def [T] (Union[T`1, None]) -> Union
30022989
[builtins fixtures/list.pyi]
30032990

30042991
[case testInferenceAgainstGenericSplitOrder]
3005-
# flags: --new-type-inference
30062992
from typing import TypeVar, Callable, List
30072993

30082994
S = TypeVar('S')
@@ -3017,7 +3003,6 @@ reveal_type(dec(id, id)) # N: Revealed type is "def (builtins.int) -> builtins.
30173003
[builtins fixtures/list.pyi]
30183004

30193005
[case testInferenceAgainstGenericSplitOrderGeneric]
3020-
# flags: --new-type-inference
30213006
from typing import TypeVar, Callable, Tuple
30223007

30233008
S = TypeVar('S')
@@ -3048,7 +3033,6 @@ reveal_type(id) # N: Revealed type is "def (builtins.int) -> builtins.int"
30483033
[builtins fixtures/tuple.pyi]
30493034

30503035
[case testInferenceAgainstGenericEllipsisSelfSpecialCase]
3051-
# flags: --new-type-inference
30523036
from typing import Self, Callable, TypeVar
30533037

30543038
T = TypeVar("T")
@@ -3062,7 +3046,6 @@ c: C
30623046
reveal_type(c.test()) # N: Revealed type is "__main__.C"
30633047

30643048
[case testInferenceAgainstGenericBoundsAndValues]
3065-
# flags: --new-type-inference
30663049
from typing import TypeVar, Callable, List
30673050

30683051
class B: ...
@@ -3090,7 +3073,6 @@ reveal_type(dec2(id2)) # N: Revealed type is "def (Never) -> builtins.list[Neve
30903073
# E: Argument 1 to "dec2" has incompatible type "Callable[[V], V]"; expected "Callable[[Never], Never]"
30913074

30923075
[case testInferenceAgainstGenericLambdas]
3093-
# flags: --new-type-inference
30943076
from typing import TypeVar, Callable, List
30953077

30963078
S = TypeVar('S')
@@ -3127,7 +3109,6 @@ dec4_bound(lambda x: x) # E: Value of type variable "I" of "dec4_bound" cannot
31273109
[builtins fixtures/list.pyi]
31283110

31293111
[case testInferenceAgainstGenericParamSpecBasicInList]
3130-
# flags: --new-type-inference
31313112
from typing import TypeVar, Callable, List, Tuple
31323113
from typing_extensions import ParamSpec
31333114

@@ -3146,7 +3127,6 @@ reveal_type(dec(pair)) # N: Revealed type is "def [U, V] (x: U`-1, y: V`-2) ->
31463127
[builtins fixtures/list.pyi]
31473128

31483129
[case testInferenceAgainstGenericParamSpecBasicDeList]
3149-
# flags: --new-type-inference
31503130
from typing import TypeVar, Callable, List, Tuple
31513131
from typing_extensions import ParamSpec
31523132

@@ -3163,7 +3143,6 @@ reveal_type(dec(either)) # N: Revealed type is "def [T] (x: builtins.list[T`5],
31633143
[builtins fixtures/list.pyi]
31643144

31653145
[case testInferenceAgainstGenericParamSpecPopOff]
3166-
# flags: --new-type-inference
31673146
from typing import TypeVar, Callable, List, Tuple
31683147
from typing_extensions import ParamSpec, Concatenate
31693148

@@ -3184,7 +3163,6 @@ reveal_type(dec(dec)) # N: Revealed type is "def () -> def [T, P, S] (def (T`-1
31843163
[builtins fixtures/list.pyi]
31853164

31863165
[case testInferenceAgainstGenericParamSpecPopOn]
3187-
# flags: --new-type-inference
31883166
from typing import TypeVar, Callable, List, Tuple
31893167
from typing_extensions import ParamSpec, Concatenate
31903168

@@ -3206,7 +3184,6 @@ reveal_type(dec(dec)) # N: Revealed type is "def [T, S] (T`13, f: def () -> def
32063184
[builtins fixtures/list.pyi]
32073185

32083186
[case testInferenceAgainstGenericParamSpecVsParamSpec]
3209-
# flags: --new-type-inference
32103187
from typing import TypeVar, Callable, List, Tuple, Generic
32113188
from typing_extensions import ParamSpec, Concatenate
32123189

@@ -3227,7 +3204,6 @@ reveal_type(dec(h)) # N: Revealed type is "def [T, Q] (T`-1, *Q.args, **Q.kwarg
32273204
[builtins fixtures/list.pyi]
32283205

32293206
[case testInferenceAgainstGenericParamSpecVsParamSpecConcatenate]
3230-
# flags: --new-type-inference
32313207
from typing import TypeVar, Callable, List, Tuple, Generic
32323208
from typing_extensions import ParamSpec, Concatenate
32333209

@@ -3245,7 +3221,6 @@ reveal_type(dec(h)) # N: Revealed type is "def [T, Q] (T`-1, *Q.args, **Q.kwarg
32453221
[builtins fixtures/list.pyi]
32463222

32473223
[case testInferenceAgainstGenericParamSpecSecondary]
3248-
# flags: --new-type-inference
32493224
from typing import TypeVar, Callable, List, Tuple, Generic
32503225
from typing_extensions import ParamSpec, Concatenate
32513226

@@ -3263,7 +3238,6 @@ reveal_type(dec(g)) # N: Revealed type is "def (builtins.int) -> __main__.Foo[[
32633238
[builtins fixtures/list.pyi]
32643239

32653240
[case testInferenceAgainstGenericParamSpecSecondOrder]
3266-
# flags: --new-type-inference
32673241
from typing import TypeVar, Callable
32683242
from typing_extensions import ParamSpec, Concatenate
32693243

@@ -3285,7 +3259,6 @@ reveal_type(transform(dec2)) # N: Revealed type is "def [W, T] (def (builtins.i
32853259
[builtins fixtures/tuple.pyi]
32863260

32873261
[case testNoAccidentalVariableClashInNestedGeneric]
3288-
# flags: --new-type-inference
32893262
from typing import TypeVar, Callable, Generic, Tuple
32903263

32913264
T = TypeVar('T')
@@ -3302,7 +3275,6 @@ def apply(a: S, b: T) -> None:
33023275
[builtins fixtures/tuple.pyi]
33033276

33043277
[case testInferenceAgainstGenericParamSpecSpuriousBoundsNotUsed]
3305-
# flags: --new-type-inference
33063278
from typing import TypeVar, Callable, Generic
33073279
from typing_extensions import ParamSpec, Concatenate
33083280

@@ -3321,7 +3293,6 @@ reveal_type(test) # N: Revealed type is "def () -> def [Q] (__main__.Foo[Q`-1])
33213293
[builtins fixtures/tuple.pyi]
33223294

33233295
[case testInferenceAgainstGenericVariadicBasicInList]
3324-
# flags: --new-type-inference
33253296
from typing import Tuple, TypeVar, List, Callable
33263297
from typing_extensions import Unpack, TypeVarTuple
33273298

@@ -3341,7 +3312,6 @@ reveal_type(dec(pair)) # N: Revealed type is "def [U, V] (U`-1, V`-2) -> builti
33413312
[builtins fixtures/tuple.pyi]
33423313

33433314
[case testInferenceAgainstGenericVariadicBasicDeList]
3344-
# flags: --new-type-inference
33453315
from typing import Tuple, TypeVar, List, Callable
33463316
from typing_extensions import Unpack, TypeVarTuple
33473317

@@ -3359,7 +3329,6 @@ reveal_type(dec(either)) # N: Revealed type is "def [T] (builtins.list[T`5], bu
33593329
[builtins fixtures/tuple.pyi]
33603330

33613331
[case testInferenceAgainstGenericVariadicPopOff]
3362-
# flags: --new-type-inference
33633332
from typing import TypeVar, Callable, List, Tuple
33643333
from typing_extensions import Unpack, TypeVarTuple
33653334

@@ -3381,7 +3350,6 @@ reveal_type(dec(dec)) # N: Revealed type is "def () -> def [T, Ts, S] (def (T`-
33813350
[builtins fixtures/list.pyi]
33823351

33833352
[case testInferenceAgainstGenericVariadicPopOn]
3384-
# flags: --new-type-inference
33853353
from typing import TypeVar, Callable, List, Tuple
33863354
from typing_extensions import Unpack, TypeVarTuple
33873355

@@ -3404,7 +3372,6 @@ reveal_type(dec(dec)) # N: Revealed type is "def [T, S] (T`13, def () -> def (T
34043372
[builtins fixtures/list.pyi]
34053373

34063374
[case testInferenceAgainstGenericVariadicVsVariadic]
3407-
# flags: --new-type-inference
34083375
from typing import TypeVar, Callable, List, Generic
34093376
from typing_extensions import Unpack, TypeVarTuple
34103377

@@ -3424,7 +3391,6 @@ reveal_type(dec(g)) # N: Revealed type is "def [Ts] (*Unpack[Ts`4]) -> builtins
34243391
[builtins fixtures/list.pyi]
34253392

34263393
[case testInferenceAgainstGenericVariadicVsVariadicConcatenate]
3427-
# flags: --new-type-inference
34283394
from typing import TypeVar, Callable, Generic
34293395
from typing_extensions import Unpack, TypeVarTuple
34303396

@@ -3443,7 +3409,6 @@ reveal_type(dec(h)) # N: Revealed type is "def [T, Us] (T`-1, *Unpack[Us`-2]) -
34433409
[builtins fixtures/list.pyi]
34443410

34453411
[case testInferenceAgainstGenericVariadicSecondary]
3446-
# flags: --new-type-inference
34473412
from typing import TypeVar, Callable, Generic
34483413
from typing_extensions import Unpack, TypeVarTuple
34493414

test-data/unit/check-inference-context.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,6 @@ f(lambda: None)
693693
g(lambda: None)
694694

695695
[case testIsinstanceInInferredLambda]
696-
# flags: --new-type-inference
697696
from typing import TypeVar, Callable, Optional
698697
T = TypeVar('T')
699698
S = TypeVar('S')

test-data/unit/check-inference.test

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,14 +1405,12 @@ class B: pass
14051405
[builtins fixtures/list.pyi]
14061406

14071407
[case testUninferableLambda]
1408-
# flags: --new-type-inference
14091408
from typing import TypeVar, Callable
14101409
X = TypeVar('X')
14111410
def f(x: Callable[[X], X]) -> X: pass
14121411
y = f(lambda x: x) # E: Need type annotation for "y"
14131412

14141413
[case testUninferableLambdaWithTypeError]
1415-
# flags: --new-type-inference
14161414
from typing import TypeVar, Callable
14171415
X = TypeVar('X')
14181416
def f(x: Callable[[X], X], y: str) -> X: pass

test-data/unit/check-overloading.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6637,7 +6637,6 @@ reveal_type(Snafu.snafu('123')) # N: Revealed type is "builtins.str"
66376637
[builtins fixtures/staticmethod.pyi]
66386638

66396639
[case testOverloadedWithInternalTypeVars]
6640-
# flags: --new-type-inference
66416640
import m
66426641

66436642
[file m.pyi]

test-data/unit/check-parameter-specification.test

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,6 @@ reveal_type(jf(1)) # N: Revealed type is "None"
11211121
[builtins fixtures/paramspec.pyi]
11221122

11231123
[case testGenericsInInferredParamspecReturn]
1124-
# flags: --new-type-inference
11251124
from typing import Callable, TypeVar, Generic
11261125
from typing_extensions import ParamSpec
11271126

@@ -1646,7 +1645,6 @@ def f(f: Callable[P, None], *args: P.args, **kwargs: P.kwargs) -> None: ...
16461645
[builtins fixtures/paramspec.pyi]
16471646

16481647
[case testParamSpecDecoratorAppliedToGeneric]
1649-
# flags: --new-type-inference
16501648
from typing import Callable, List, TypeVar
16511649
from typing_extensions import ParamSpec
16521650

@@ -1684,7 +1682,6 @@ reveal_type(test(*ints)) # N: Revealed type is "__main__.Foo[[*builtins.int]]"
16841682
[builtins fixtures/paramspec.pyi]
16851683

16861684
[case testParamSpecArgumentParamInferenceGeneric]
1687-
# flags: --new-type-inference
16881685
from typing import Callable, TypeVar
16891686
from typing_extensions import ParamSpec
16901687

@@ -1702,7 +1699,6 @@ y: int = call(identity, 2)
17021699
[builtins fixtures/paramspec.pyi]
17031700

17041701
[case testParamSpecNestedApplyNoCrash]
1705-
# flags: --new-type-inference
17061702
from typing import Callable, TypeVar
17071703
from typing_extensions import ParamSpec
17081704

test-data/unit/check-plugin-attrs.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,6 @@ class A:
12011201
[builtins fixtures/bool.pyi]
12021202

12031203
[case testAttrsFactoryBadReturn]
1204-
# flags: --new-type-inference
12051204
import attr
12061205
def my_factory() -> int:
12071206
return 7

test-data/unit/check-typevar-tuple.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,6 @@ reveal_type(z) # N: Revealed type is "tuple[builtins.int, Unpack[builtins.tuple
886886
[builtins fixtures/tuple.pyi]
887887

888888
[case testInferenceAgainstGenericVariadicWithBadType]
889-
# flags: --new-type-inference
890889
from typing import TypeVar, Callable, Generic
891890
from typing_extensions import Unpack, TypeVarTuple
892891

0 commit comments

Comments
 (0)