-
Notifications
You must be signed in to change notification settings - Fork 68
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
fix: add support for PEP 585 type hinting for 3.9+ #199
base: dev
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #199 +/- ##
==========================================
+ Coverage 92.97% 92.98% +0.01%
==========================================
Files 56 56
Lines 3187 3194 +7
Branches 649 651 +2
==========================================
+ Hits 2963 2970 +7
Misses 137 137
Partials 87 87
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
""" | ||
origin = get_origin(annotation) | ||
if sys.version_info >= (3, 9): | ||
is_iterable_anno = (origin is not None |
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.
Why is typing_inspect.is_generic_type(annotation)
not included in >3.9?
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.
is_generic_type
will fail for the list
type -- this is a method we defined. get_origin
expands on our definition of is_generic_type
but includes the built-in collection types. get_origin
supports the generic types and returns a non-None value where is_generic_type
would return true
This PR introduces compatibility with PEP 585 type hinting in the Azure Functions Python Worker. PEP 585, introduced in Python 3.9, allows for the use of built-in collection types (like list and dict) as generic type hints, offering a more concise and readable syntax.
addressing Azure/azure-functions-python-worker#1034