-
-
Notifications
You must be signed in to change notification settings - Fork 117
Make typing_extensions a drop in for typing #50
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
Comments
I would be fine with this, but I am mostly indifferent to it. |
Yeah, this is very inconvenient. I tried using it as a drop-in replacement because we have dozens of files, but it doesn't work:
yields
|
Effectively we needed to do things like
which is a labor-intensive process and not that maintainable. |
I'm sympathetic to this idea; it's hard to remember what you need to import from typing-extensions depending on the Python version. At runtime we can simply add For reference, these are the names in
|
I also quite like this idea (though I don't feel particularly strongly about it, like @srittau). @JelleZijlstra's suggested implementation sounds good to me. |
Thanks @JelleZijlstra! It would really help with our use case. As a side note, we tried to patch it somehow: if sys.version_info < (3, 8):
from typing_extensions import get_origin as get_origin_typing_extensions
def get_origin_wrapped(t):
if sys.version_info < (3, 8):
return get_origin_typing_extensions(t)
return typing.get_origin(t)
setattr(typing, "Literal", typing_extensions.Literal)
setattr(typing, "get_origin", get_origin_wrapped) |
Yes, please it's a huge pain to use both |
Fixes python#50. I decided to exclude top-level names that have a definite removal timeline (io, re, ByteString); there's no point in re-exporting them now. Many other names are deprecated without a definite removal plan (PEP 585). If they do get removed eventually, typing-extensions can simply re-export the builtin/collections.abc names. In the documentation, I add a separate section listing all the names that are pure aliases for typing. This makes it easier to distinguish the cases where there is something more interesting going on in typing-extensions.
PR in #196. I didn't do the |
* Re-export all names from typing Fixes #50. I decided to exclude top-level names that have a definite removal timeline (io, re, ByteString); there's no point in re-exporting them now. Many other names are deprecated without a definite removal plan (PEP 585). If they do get removed eventually, typing-extensions can simply re-export the builtin/collections.abc names. In the documentation, I add a separate section listing all the names that are pure aliases for typing. This makes it easier to distinguish the cases where there is something more interesting going on in typing-extensions. Co-authored-by: Alex Waygood <[email protected]> Co-authored-by: Shantanu <[email protected]>
Currently I find it annoying trying to remember which types from typing_extensions are and aren't in the versions of typing that I have access to. I think this could be solved by making typing_extensions a fully drop in replacement. I think this would also help with some older issues like subclassing Generic with a ParamSpec as a parameter used to be.
#50 (comment)
The text was updated successfully, but these errors were encountered: