You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: only install typing-extensions dependency when necessary #280
typing-extensions module is a backport for typing hint for old versions of python <= 3.5
in this project many times typing-extensions is imported to use the Literal type hint which is already natively included in python >= 3.8
Motivation
There is no need for this package in Python >= 3.8 and we are currently enforced to install it
Proposal
add if try/except blocks based on the python version
# aws_lambda_powertools/utilities/parser/types.pyimportsysifsys.version_info[0] >=3andsys.version_info[1] >=8:
fromtypingimportLiteral# noqa: F401else:
try:
fromtyping_extensionsimportLiteral# noqa: F401exceptImportError:
raiseException("please install typing-extensions or upgrade to Python >= 3.8")
this is not really a design, it's more a check to wether import typing-extensions or not based on the system python version
in order to use it right instead of importing typing_extensions we can include the dependency in the file types.py and then import that dependency from the types.py as showed in the code blocks
Drawbacks
since this is not a design it's more an improvement of a dependency import I don't see a drawback
Rationale and alternatives
What is the impact of not doing this?
The impact of not doing this will be the used of a backport library which is not needed by the interpreter as it has the native implementation
changed the title [-]RFC: python38 does not need typing-extensions dependency[/-][+]feat: only install typing-extensions dependency when necessary[/+]on Feb 3, 2021
Activity
[-]RFC: python38 does not need typing-extensions dependency[/-][+]feat: only install typing-extensions dependency when necessary[/+]to-mc commentedon Feb 3, 2021
Thanks @nadobando! I'll have a look at the PR shortly.
heitorlessa commentedon Feb 4, 2021
Now available in 1.10.2! Thank you very much for this
hasnain2808 commentedon Nov 6, 2024
@nadobando
typing-extensions are also needed in say, version 3.8 to use type hints from later versions
https://pypi.org/project/typing-extensions/#description