Skip to content

Improve accuracy of six byte index methods #9117

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

Merged
merged 11 commits into from
Nov 10, 2022
Merged
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
Added back to allowlist
  • Loading branch information
Avasam committed Nov 7, 2022
commit b438335993fd925ef95d2eb063e8bb955d094357
9 changes: 7 additions & 2 deletions stdlib/_operator.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,13 @@ class itemgetter(Generic[_T_co]):
# mypy lacks support for PEP 646 https://github.com/python/mypy/issues/12280
@overload
def __new__(cls, *items: _T_co) -> itemgetter[tuple[_T_co, ...]]: ...
# A bug in mypy prevents using _T instead of Any here.
def __call__(self, obj: SupportsGetItem[_T_co, Any]) -> Any: ...
# __key: _KT_contra in SupportsGetItem seems to be causing variance issues, ie:
# TypeVar "_KT_contra@SupportsGetItem" is contravariant
# "tuple[int, int]" is incompatible with protocol "SupportsIndex"
# preventing [_T_co, ...] instead of [Any, ...]
#
# A bug in mypy prevents using [..., _T] instead of [..., Any] here.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should link to the bug in the mypy issue tracker.

def __call__(self, obj: SupportsGetItem[Any, Any]) -> Any: ...

@final
class methodcaller:
Expand Down
2 changes: 2 additions & 0 deletions stubs/six/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ six.get_method_self
six.viewitems
six.viewkeys
six.viewvalues
# Should be `operator.itemgetter[int]`. But a bug in mypy prevents using TypeVar in itemgetter__call__
six.byte2int

# Unclear problems
six.callable
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy