Skip to content

Commit 3f601c3

Browse files
authored
Remove unneeded --strict-optional flags from test cases (#15684)
1 parent 3240da4 commit 3f601c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+58
-248
lines changed

test-data/unit/check-abstract.test

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,6 @@ b.y = 1
11251125
-- -----------------------------------------------
11261126

11271127
[case testEmptyBodyProhibitedFunction]
1128-
# flags: --strict-optional
11291128
from typing import overload, Union
11301129

11311130
def func1(x: str) -> int: pass # E: Missing return statement
@@ -1148,7 +1147,6 @@ def func5(x: Union[int, str]) -> Union[int, str]: # E: Missing return statement
11481147
"""Some function."""
11491148

11501149
[case testEmptyBodyProhibitedMethodNonAbstract]
1151-
# flags: --strict-optional
11521150
from typing import overload, Union
11531151

11541152
class A:
@@ -1183,7 +1181,6 @@ class C:
11831181
[builtins fixtures/classmethod.pyi]
11841182

11851183
[case testEmptyBodyProhibitedPropertyNonAbstract]
1186-
# flags: --strict-optional
11871184
class A:
11881185
@property
11891186
def x(self) -> int: ... # E: Missing return statement
@@ -1212,7 +1209,6 @@ class C:
12121209
[builtins fixtures/property.pyi]
12131210

12141211
[case testEmptyBodyNoteABCMeta]
1215-
# flags: --strict-optional
12161212
from abc import ABC
12171213

12181214
class A(ABC):
@@ -1221,7 +1217,6 @@ class A(ABC):
12211217
...
12221218

12231219
[case testEmptyBodyAllowedFunctionStub]
1224-
# flags: --strict-optional
12251220
import stub
12261221
[file stub.pyi]
12271222
from typing import overload, Union
@@ -1232,7 +1227,6 @@ def func3(x: str) -> int:
12321227
"""Some function."""
12331228

12341229
[case testEmptyBodyAllowedMethodNonAbstractStub]
1235-
# flags: --strict-optional
12361230
import stub
12371231
[file stub.pyi]
12381232
from typing import overload, Union
@@ -1254,7 +1248,6 @@ class B:
12541248
[builtins fixtures/classmethod.pyi]
12551249

12561250
[case testEmptyBodyAllowedPropertyNonAbstractStub]
1257-
# flags: --strict-optional
12581251
import stub
12591252
[file stub.pyi]
12601253
class A:
@@ -1285,7 +1278,6 @@ class C:
12851278
[builtins fixtures/property.pyi]
12861279

12871280
[case testEmptyBodyAllowedMethodAbstract]
1288-
# flags: --strict-optional
12891281
from typing import overload, Union
12901282
from abc import abstractmethod
12911283

@@ -1333,7 +1325,6 @@ class C:
13331325
[builtins fixtures/classmethod.pyi]
13341326

13351327
[case testEmptyBodyAllowedPropertyAbstract]
1336-
# flags: --strict-optional
13371328
from abc import abstractmethod
13381329
class A:
13391330
@property
@@ -1372,7 +1363,6 @@ class C:
13721363
[builtins fixtures/property.pyi]
13731364

13741365
[case testEmptyBodyImplicitlyAbstractProtocol]
1375-
# flags: --strict-optional
13761366
from typing import Protocol, overload, Union
13771367

13781368
class P1(Protocol):
@@ -1413,7 +1403,6 @@ C3()
14131403
[builtins fixtures/classmethod.pyi]
14141404

14151405
[case testEmptyBodyImplicitlyAbstractProtocolProperty]
1416-
# flags: --strict-optional
14171406
from typing import Protocol
14181407

14191408
class P1(Protocol):
@@ -1443,7 +1432,6 @@ C2()
14431432
[builtins fixtures/property.pyi]
14441433

14451434
[case testEmptyBodyImplicitlyAbstractProtocolStub]
1446-
# flags: --strict-optional
14471435
from stub import P1, P2, P3, P4
14481436

14491437
class B1(P1): ...
@@ -1479,7 +1467,6 @@ class P4(Protocol):
14791467
[builtins fixtures/classmethod.pyi]
14801468

14811469
[case testEmptyBodyUnsafeAbstractSuper]
1482-
# flags: --strict-optional
14831470
from stub import StubProto, StubAbstract
14841471
from typing import Protocol
14851472
from abc import abstractmethod
@@ -1528,7 +1515,6 @@ class StubAbstract:
15281515
def meth(self) -> int: ...
15291516

15301517
[case testEmptyBodyUnsafeAbstractSuperProperty]
1531-
# flags: --strict-optional
15321518
from stub import StubProto, StubAbstract
15331519
from typing import Protocol
15341520
from abc import abstractmethod
@@ -1586,7 +1572,6 @@ class StubAbstract:
15861572
[builtins fixtures/property.pyi]
15871573

15881574
[case testEmptyBodyUnsafeAbstractSuperOverloads]
1589-
# flags: --strict-optional
15901575
from stub import StubProto
15911576
from typing import Protocol, overload, Union
15921577

@@ -1671,7 +1656,6 @@ class SubAbstract(Abstract):
16711656
return super().meth()
16721657

16731658
[case testEmptyBodyNoSuperWarningOptionalReturn]
1674-
# flags: --strict-optional
16751659
from typing import Protocol, Optional
16761660
from abc import abstractmethod
16771661

@@ -1689,7 +1673,6 @@ class SubAbstract(Abstract):
16891673
return super().meth()
16901674

16911675
[case testEmptyBodyTypeCheckingOnly]
1692-
# flags: --strict-optional
16931676
from typing import TYPE_CHECKING
16941677

16951678
class C:

test-data/unit/check-basic.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@ y = x # E: Incompatible types in assignment (expression has type "Dict[str, int]
385385
[builtins fixtures/dict.pyi]
386386

387387
[case testDistinctTypes]
388-
# flags: --strict-optional
389388
import b
390389

391390
[file a.py]

test-data/unit/check-class-namedtuple.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ UserDefined(1) # E: Argument 1 to "UserDefined" has incompatible type "int"; ex
419419
[builtins fixtures/list.pyi]
420420

421421
[case testNewNamedTupleWithDefaultsStrictOptional]
422-
# flags: --strict-optional
423422
from typing import List, NamedTuple, Optional
424423

425424
class HasNone(NamedTuple):

test-data/unit/check-classes.test

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,6 @@ if int():
935935
b = D2()
936936

937937
[case testConstructorJoinsWithCustomMetaclass]
938-
# flags: --strict-optional
939938
from typing import TypeVar
940939
import abc
941940

@@ -1629,7 +1628,6 @@ a = A()
16291628
reveal_type(a.f) # N: Revealed type is "__main__.D"
16301629

16311630
[case testAccessingDescriptorFromClass]
1632-
# flags: --strict-optional
16331631
from d import D, Base
16341632
class A(Base):
16351633
f = D()
@@ -1647,7 +1645,6 @@ class D:
16471645
[builtins fixtures/bool.pyi]
16481646

16491647
[case testAccessingDescriptorFromClassWrongBase]
1650-
# flags: --strict-optional
16511648
from d import D, Base
16521649
class A:
16531650
f = D()
@@ -1664,13 +1661,13 @@ class D:
16641661
def __get__(self, inst: Base, own: Type[Base]) -> str: pass
16651662
[builtins fixtures/bool.pyi]
16661663
[out]
1667-
main:5: error: Argument 2 to "__get__" of "D" has incompatible type "Type[A]"; expected "Type[Base]"
1668-
main:5: note: Revealed type is "d.D"
1669-
main:6: error: No overload variant of "__get__" of "D" matches argument types "A", "Type[A]"
1670-
main:6: note: Possible overload variants:
1671-
main:6: note: def __get__(self, inst: None, own: Type[Base]) -> D
1672-
main:6: note: def __get__(self, inst: Base, own: Type[Base]) -> str
1673-
main:6: note: Revealed type is "Any"
1664+
main:4: error: Argument 2 to "__get__" of "D" has incompatible type "Type[A]"; expected "Type[Base]"
1665+
main:4: note: Revealed type is "d.D"
1666+
main:5: error: No overload variant of "__get__" of "D" matches argument types "A", "Type[A]"
1667+
main:5: note: Possible overload variants:
1668+
main:5: note: def __get__(self, inst: None, own: Type[Base]) -> D
1669+
main:5: note: def __get__(self, inst: Base, own: Type[Base]) -> str
1670+
main:5: note: Revealed type is "Any"
16741671

16751672
[case testAccessingGenericNonDataDescriptor]
16761673
from typing import TypeVar, Type, Generic, Any
@@ -1702,7 +1699,6 @@ a.g = ''
17021699
a.g = 1 # E: Incompatible types in assignment (expression has type "int", variable has type "str")
17031700

17041701
[case testAccessingGenericDescriptorFromClass]
1705-
# flags: --strict-optional
17061702
from d import D
17071703
class A:
17081704
f = D(10) # type: D[A, int]
@@ -1724,7 +1720,6 @@ class D(Generic[T, V]):
17241720
[builtins fixtures/bool.pyi]
17251721

17261722
[case testAccessingGenericDescriptorFromInferredClass]
1727-
# flags: --strict-optional
17281723
from typing import Type
17291724
from d import D
17301725
class A:
@@ -1745,11 +1740,10 @@ class D(Generic[T, V]):
17451740
def __get__(self, inst: T, own: Type[T]) -> V: pass
17461741
[builtins fixtures/bool.pyi]
17471742
[out]
1748-
main:8: note: Revealed type is "d.D[__main__.A, builtins.int]"
1749-
main:9: note: Revealed type is "d.D[__main__.A, builtins.str]"
1743+
main:7: note: Revealed type is "d.D[__main__.A, builtins.int]"
1744+
main:8: note: Revealed type is "d.D[__main__.A, builtins.str]"
17501745

17511746
[case testAccessingGenericDescriptorFromClassBadOverload]
1752-
# flags: --strict-optional
17531747
from d import D
17541748
class A:
17551749
f = D(10) # type: D[A, int]
@@ -1766,11 +1760,11 @@ class D(Generic[T, V]):
17661760
def __get__(self, inst: T, own: Type[T]) -> V: pass
17671761
[builtins fixtures/bool.pyi]
17681762
[out]
1769-
main:5: error: No overload variant of "__get__" of "D" matches argument types "None", "Type[A]"
1770-
main:5: note: Possible overload variants:
1771-
main:5: note: def __get__(self, inst: None, own: None) -> D[A, int]
1772-
main:5: note: def __get__(self, inst: A, own: Type[A]) -> int
1773-
main:5: note: Revealed type is "Any"
1763+
main:4: error: No overload variant of "__get__" of "D" matches argument types "None", "Type[A]"
1764+
main:4: note: Possible overload variants:
1765+
main:4: note: def __get__(self, inst: None, own: None) -> D[A, int]
1766+
main:4: note: def __get__(self, inst: A, own: Type[A]) -> int
1767+
main:4: note: Revealed type is "Any"
17741768

17751769
[case testAccessingNonDataDescriptorSubclass]
17761770
from typing import Any
@@ -6484,7 +6478,6 @@ def deco(f: Callable[..., T]) -> Callable[..., Tuple[T, int]]: ...
64846478
[out]
64856479

64866480
[case testOptionalDescriptorsBinder]
6487-
# flags: --strict-optional
64886481
from typing import Type, TypeVar, Optional
64896482
T = TypeVar('T')
64906483

@@ -6698,7 +6691,6 @@ class C(Generic[T]):
66986691
[builtins fixtures/isinstancelist.pyi]
66996692

67006693
[case testIsInstanceTypeSubclass]
6701-
# flags: --strict-optional
67026694
from typing import Type, Optional
67036695
class Base: ...
67046696
class One(Base):

test-data/unit/check-columns.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ A().f(1, 1) # E:10: Argument 2 to "f" of "A" has incompatible type "int"; expect
2727
(A().f(1, 'hello', 'hi')) # E:2: Too many arguments for "f" of "A"
2828

2929
[case testColumnsInvalidArgumentType]
30-
# flags: --strict-optional
3130
def f(x: int, y: str) -> None: ...
3231
def g(*x: int) -> None: pass
3332
def h(**x: int) -> None: pass

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ else:
802802
plugins=<ROOT>/test-data/unit/plugins/union_method.py
803803

804804
[case testGetMethodHooksOnUnionsStrictOptional]
805-
# flags: --config-file tmp/mypy.ini --strict-optional
805+
# flags: --config-file tmp/mypy.ini
806806
from typing import Union
807807

808808
class Foo:

test-data/unit/check-dataclasses.test

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,6 @@ class Foo:
11271127

11281128
[case testNoComplainFieldNoneStrict]
11291129
# flags: --python-version 3.7
1130-
# flags: --strict-optional
11311130
from dataclasses import dataclass, field
11321131
from typing import Optional
11331132

@@ -1264,7 +1263,7 @@ class Deferred: pass
12641263
[builtins fixtures/dataclasses.pyi]
12651264

12661265
[case testDeferredDataclassInitSignatureSubclass]
1267-
# flags: --strict-optional --python-version 3.7
1266+
# flags: --python-version 3.7
12681267
from dataclasses import dataclass
12691268
from typing import Optional
12701269

@@ -1745,7 +1744,7 @@ reveal_type(Child2[int, A]([A()], [1]).b) # N: Revealed type is "builtins.list[
17451744
[builtins fixtures/dataclasses.pyi]
17461745

17471746
[case testDataclassInheritOptionalType]
1748-
# flags: --python-version 3.7 --strict-optional
1747+
# flags: --python-version 3.7
17491748
from dataclasses import dataclass
17501749
from typing import Any, Callable, Generic, TypeVar, List, Optional
17511750

@@ -1979,7 +1978,6 @@ B = List[C]
19791978
[builtins fixtures/dataclasses.pyi]
19801979

19811980
[case testDataclassSelfType]
1982-
# flags: --strict-optional
19831981
from dataclasses import dataclass
19841982
from typing import Self, TypeVar, Generic, Optional
19851983

@@ -2104,7 +2102,6 @@ a2 = replace(a, q='42') # E: Argument "q" to "replace" of "A" has incompatible
21042102
reveal_type(a2) # N: Revealed type is "__main__.A"
21052103

21062104
[case testReplaceUnion]
2107-
# flags: --strict-optional
21082105
from typing import Generic, Union, TypeVar
21092106
from dataclasses import dataclass, replace, InitVar
21102107

@@ -2136,7 +2133,6 @@ _ = replace(a_or_b, y=42, init_var=42) # E: Argument "y" to "replace" of "Union
21362133
[builtins fixtures/dataclasses.pyi]
21372134

21382135
[case testReplaceUnionOfTypeVar]
2139-
# flags: --strict-optional
21402136
from typing import Generic, Union, TypeVar
21412137
from dataclasses import dataclass, replace
21422138

test-data/unit/check-enum.test

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,6 @@ else:
953953
[builtins fixtures/bool.pyi]
954954

955955
[case testEnumReachabilityWithNone]
956-
# flags: --strict-optional
957956
from enum import Enum
958957
from typing import Optional
959958

@@ -1016,7 +1015,6 @@ reveal_type(x3) # N: Revealed type is "Union[__main__.Foo, __main__.Bar]"
10161015
[builtins fixtures/bool.pyi]
10171016

10181017
[case testEnumReachabilityPEP484ExampleWithFinal]
1019-
# flags: --strict-optional
10201018
from typing import Union
10211019
from typing_extensions import Final
10221020
from enum import Enum
@@ -1063,7 +1061,6 @@ def process(response: Union[str, Reason] = '') -> str:
10631061

10641062

10651063
[case testEnumReachabilityPEP484ExampleSingleton]
1066-
# flags: --strict-optional
10671064
from typing import Union
10681065
from typing_extensions import Final
10691066
from enum import Enum
@@ -1088,7 +1085,6 @@ def func(x: Union[int, None, Empty] = _empty) -> int:
10881085
[builtins fixtures/primitives.pyi]
10891086

10901087
[case testEnumReachabilityPEP484ExampleSingletonWithMethod]
1091-
# flags: --strict-optional
10921088
from typing import Union
10931089
from typing_extensions import Final
10941090
from enum import Enum

0 commit comments

Comments
 (0)