GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix strict optional with generic defaults (#21788) · python/mypy@60fa82e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • mypy
    • typeanal.py
  • test-data/unit
    • check-expressions.test
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎mypy/typeanal.py‎

Copy file name to clipboardExpand all lines: mypy/typeanal.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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)
Collapse file

‎test-data/unit/check-expressions.test‎

Copy file name to clipboardExpand all lines: test-data/unit/check-expressions.test
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff 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]
12521274
from typing import Any
12531275
a: Any

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.