-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Update importlib resources for 3.13 #12298
Conversation
if sys.version_info >= (3, 13): | ||
def open_binary(anchor: Anchor, *path_names: StrPath) -> BinaryIO: ... | ||
@overload | ||
def open_text(anchor: Anchor, *path_names: *tuple[StrPath], encoding: str = "utf-8", errors: str = "strict") -> TextIO: ... |
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 one path name is provided, the encoding defaults to utf-8, otherwise it's required: https://github.com/python/cpython/blob/3.13/Lib/importlib/resources/_functional.py#L67
This comment has been minimized.
This comment has been minimized.
There's a merge conflict in the allowlist now. |
This comment has been minimized.
This comment has been minimized.
Package: TypeAlias = str | ModuleType | ||
|
||
if sys.version_info >= (3, 11): | ||
Resource: TypeAlias = str | ||
else: | ||
if sys.version_info >= (3, 13): | ||
Anchor: TypeAlias = Package |
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.
I'd put these into ._common
, like in the implementation (introduced in Python 3.11). Or at least Anchor
, since it was newly introduced.
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.
Fixed! 9cc4585
This comment has been minimized.
This comment has been minimized.
3 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@srittau It seems we're still running stubtest on |
I've added two suggestions that will hopefully help. |
@@ -204,3 +194,7 @@ codecs.namereplace_errors | |||
codecs.replace_errors | |||
codecs.strict_errors | |||
codecs.xmlcharrefreplace_errors | |||
|
|||
# Runtime dynamically renames kwargs |
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.
Runtime uses a decorator to support the leagcy kwargs: https://github.com/python/cpython/blob/2bac2b86b1486f15038fb246835e04bb1b213cd8/Lib/importlib/resources/_common.py#L4
This comment has been minimized.
This comment has been minimized.
Looking at the code in mypy_test, it seems that we are not actually handling sub-modules at all when it comes to the |
This comment has been minimized.
This comment has been minimized.
The mypy errors are gone now. I have some ideas about fixing the pyright test, but I need to find some time in the next few days. |
Thanks! |
This comment has been minimized.
This comment has been minimized.
I ended up just nesting the imports under additionally type-checking blocks. While a bit more verbose, I think it works well so we can avoid false unrelated false negatives in these files. Let me know what you think! |
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
@srittau Thanks, implemented your feedback. |
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Update
importlib.resources
based on 3.13 API changes: python/cpython#116609