File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2189,7 +2189,7 @@ def fix_instance(
21892189 else :
21902190 unpacked = [arg ]
21912191 for arg in unpacked :
2192- with state .strict_optional_set (options . strict_optional ):
2192+ with state .strict_optional_set (True ):
21932193 # Gradually expand defaults, as they may depend on previous variables.
21942194 if tv .has_default ():
21952195 arg = expand_type (arg , env )
Original file line number Diff line number Diff line change @@ -1248,6 +1248,28 @@ class SupportsIndex(Protocol):
12481248 def __index__(self) -> int: ...
12491249[builtins fixtures/slice.pyi]
12501250
1251+ [case testSliceWithPerFileStrictOptional]
1252+ # flags: --no-strict-optional
1253+ # mypy: strict-optional
1254+ "x"[1:]
1255+ [file builtins.py]
1256+ from typing import Generic, TypeVar
1257+
1258+ _StartT = TypeVar("_StartT", covariant=True)
1259+ _StopT = TypeVar("_StopT", covariant=True, default=_StartT)
1260+ _StepT = TypeVar("_StepT", covariant=True, default=_StartT | _StopT)
1261+
1262+ class object:
1263+ def __init__(self) -> None: pass
1264+ class type: pass
1265+ class tuple(Generic[_StartT]): pass
1266+ class function: pass
1267+ class int: pass
1268+ class str:
1269+ def __getitem__(self, index: slice[int | None]) -> str: pass
1270+ class slice(Generic[_StartT, _StopT, _StepT]): pass
1271+ class dict: pass
1272+
12511273[case testNoneSliceBounds]
12521274from typing import Any
12531275a: Any
You can’t perform that action at this time.
0 commit comments