8000 Alternate method of handling dict.get default value by tungol · Pull Request #13224 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

Alternate method of handling dict.get default value #13224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
leave Mapping alone
  • Loading branch information
tungol committed Dec 9, 2024
commit db80c97f72d4378c66d9b15242842a569afb4429
1 change: 1 addition & 0 deletions stdlib/@tests/stubtest_allowlists/common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ _collections_abc.Generator.gi_frame
_collections_abc.Generator.gi_running
_collections_abc.Generator.gi_yieldfrom
_collections_abc.Mapping.__reversed__ # set to None at runtime for a better error message
_collections_abc.Mapping.get # Adding None to the Union messed up mypy
_collections_abc.Sequence.index # Supporting None in end is not mandatory

# Adding these reflected dunders to `typing.AbstractSet` causes a large number of false-positives. See #7414.
Expand Down
1 change: 0 additions & 1 deletion stdlib/@tests/stubtest_allowlists/py310.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ _collections_abc.Generator.send
_collections_abc.Generator.throw

# These are not positional-only at runtime, but we treat them as positional-only to match dict.
_collections_abc.Mapping.get
_collections_abc.MutableMapping.pop
_collections_abc.MutableMapping.setdefault

Expand Down
1 change: 0 additions & 1 deletion stdlib/@tests/stubtest_allowlists/py311.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ _collections_abc.Generator.send
_collections_abc.Generator.throw

# These are not positional-only at runtime, but we treat them as positional-only to match dict.
_collections_abc.Mapping.get
_collections_abc.MutableMapping.pop
_collections_abc.MutableMapping.setdefault

Expand Down
1 change: 0 additions & 1 deletion stdlib/@tests/stubtest_allowlists/py312.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ _collections_abc.Generator.send
_collections_abc.Generator.throw

# These are not positional-only at runtime, but we treat them as positional-only to match dict.
_collections_abc.Mapping.get
_collections_abc.MutableMapping.pop
_collections_abc.MutableMapping.setdefault

Expand Down
1 change: 0 additions & 1 deletion stdlib/@tests/stubtest_allowlists/py313.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ _collections_abc.Generator.send
_collections_abc.Generator.throw

# These are not positional-only at runtime, but we treat them as positional-only to match dict.
_collections_abc.Mapping.get
_collections_abc.MutableMapping.pop
_collections_abc.MutableMapping.setdefault

Expand Down
2 changes: 1 addition & 1 deletion stdlib/@tests/stubtest_allowlists/py38.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ collections.Generator.gi_frame
collections.Generator.gi_running
collections.Generator.gi_yieldfrom
collections.Mapping.__reversed__ # Set to None at runtime for a better error message
# collections.Mapping.get # Adding None to the Union messed up mypy
collections.Mapping.get # Adding None to the Union messed up mypy
collections.Sequence.index # Supporting None in end is not mandatory
xxsubtype # module missing from the stubs

Expand Down
2 changes: 1 addition & 1 deletion stdlib/@tests/stubtest_allowlists/py39.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ collections.Generator.gi_frame
collections.Generator.gi_running
collections.Generator.gi_yieldfrom
collections.Mapping.__reversed__ # Set to None at runtime for a better error message
# collections.Mapping.get # Adding None to the Union messed up mypy
collections.Mapping.get # Adding None to the Union messed up mypy
collections.Sequence.index # Supporting None in end is not mandatory
xxsubtype # module missing from the stubs

Expand Down
6 changes: 1 addition & 5 deletions stdlib/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -698,11 +698,7 @@ class Mapping(Collection[_KT], Generic[_KT, _VT_co]):
@overload
def get(self, key: _KT, /) -> _VT_co | None: ...
@overload
def get(self, key: _KT, /, default: _VT_co) -> _VT_co: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] # Covariant variable as parameter
@overload
def get(self, key: _KT, /, default: None) -> _VT_co | None: ...
@overload
def get(self, key: _KT, /, default: _T) -> _VT_co | _T: ...
def get(self, key: _KT, /, default: _VT_co | _T) -> _VT_co | _T: ...
def items(self) -> ItemsView[_KT, _VT_co]: ...
def keys(self) -> KeysView[_KT]: ...
def values(self) -> ValuesView[_VT_co]: ...
Expand Down
Loading
0