-
Notifications
You must be signed in to change notification settings - Fork 10
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
Work around various issues with Python 3.12 #222
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
from concurrent import futures | ||
from typing import ( | ||
TYPE_CHECKING, | ||
Any, | ||
NoReturn, | ||
Optional, | ||
Sequence, | ||
|
@@ -85,6 +86,16 @@ def stop(self) -> Optional[_T_co]: ... | |
@property | ||
def step(self) -> Optional[_T_co]: ... | ||
|
||
if sys.version_info >= (3, 12): | ||
|
||
@property | ||
def __orig_bases__(self) -> Any: | ||
# Only exists in Python 3.12 and above | ||
from types import get_original_bases | ||
|
||
return get_original_bases(int) | ||
# return get_original_bases(_T_co) | ||
Comment on lines
+91
to
+97
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a typeguard bug—it’s checking too many built-in attributes of the protocol that don’t actually matter. (See, for example, a case where it rejects objects with a completely empty protocol that I found. That said, if implementing this makes typeguard stop complaining for now, I would do two things:
|
||
|
||
if sys.version_info < (3, 10) and not TYPE_CHECKING: | ||
# Python 3.9 and below have a bug where any Protocol with a @property | ||
# was always regarded as runtime-checkable. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is necessary that’s fine, I guess, but this should already be covered under
ValSliceOrSequence[int]
, since that includes aSequence[int]
, which is a supertype ofTuple[int, ...]
.