Skip to content
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

Support configuration of typing vs typing_extensions #221

Closed
tobni opened this issue Aug 26, 2023 · 4 comments
Closed

Support configuration of typing vs typing_extensions #221

tobni opened this issue Aug 26, 2023 · 4 comments
Labels
🚀 enhancement New feature or request 🎉 released Changes were included to the latest release 👋 response needed Awaiting response from a reporter

Comments

@tobni
Copy link

tobni commented Aug 26, 2023

Describe your idea
I would like to enforce the library to use typing_extensions, regardless of my interpreter version.
The top level if clause in the stub files could maybe support some type of configuration, like an environment variable?
Code sample

if sys.version_info >= (3, 9) or not os.environ.get("BOTO_STUBS_USE_TYPING_EXTENSIONS"):
    from typing import TypedDict
else:
    from typing_extensions import TypedDict

Additional context
pydantic v2 requires TypedDict to be typing_extensions.TypedDict unless python is version 3.12 or higher. I cannot upgrade to this version of python, but I do want pydantics TypedDict support for parsing your generated TypedDicts.

@tobni tobni added the 🚀 enhancement New feature or request label Aug 26, 2023
@vemel
Copy link
Collaborator

vemel commented Aug 26, 2023

Hello,

Thank you for the feature request. It makes sense. However, env variables are not supported in *.pyi files, so it will not work. The solution could be to use typing_extensions if available, and fallback to typing. Another solution would be always to use typing_extensions and make it a mandatory dependency.

I will check pydantic docs.

@tobni
Copy link
Author

tobni commented Aug 26, 2023

https://docs.pydantic.dev/2.3/errors/usage_errors/#typed-dict-version is the cause for my request.

@vemel
Copy link
Collaborator

vemel commented Aug 28, 2023

I just released mypy_boto3_builder 7.18.0 with new import logic. I am going to generate all packages later today.

@vemel vemel added the 🎉 released Changes were included to the latest release label Aug 28, 2023
@vemel
Copy link
Collaborator

vemel commented Aug 29, 2023

@tobni I released all boto3-stubs packages built with the new builder version. Please test and let me know if it works as it should.

@vemel vemel added the 👋 response needed Awaiting response from a reporter label Aug 29, 2023
@vemel vemel closed this as completed Sep 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 enhancement New feature or request 🎉 released Changes were included to the latest release 👋 response needed Awaiting response from a reporter
Projects
None yet
Development

No branches or pull requests

2 participants