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

[FeatureRequest] Support Python 3.9 style hinting using standard collections per PEP 585 #1034

Open
drewsilcock opened this issue May 17, 2022 · 1 comment

Comments

@drewsilcock
Copy link

The worker supports Python 3.9, however does not work with type hinting using standard collections as specified in PEP 585 and introduced in Python 3.9.

Pre-PEP 585 style typing, which works:

from typing import List

# `func host start` is happy with this style of type hinting.
def main(events: List[func.EventHubEvent]) -> None:
    ...

New PEP 585 style typing, which doesn't work:

# `func host start` produces error here.
def main(events: list[func.EventHubEvent]) -> None:
    ...

The error produced is:

Worker failed to load function: 'my_function_name' with function id: '12345678-9012-3456-7890-abcdef123456'.
[2022-05-17T08:58:41.245Z] Result: Failure
[2022-05-17T08:58:41.245Z] Exception: TypeError: issubclass() arg 1 must be a class
[2022-05-17T08:58:41.245Z] Stack:   File "/opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.4483/workers/python/3.9/OSX/X64/azure_functions_worker/dispatcher.py", line 311, in _handle__function_load_request
[2022-05-17T08:58:41.245Z]     self._functions.add_function(
[2022-05-17T08:58:41.245Z]   File "/opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.4483/workers/python/3.9/OSX/X64/azure_functions_worker/functions.py", line 204, in add_function
[2022-05-17T08:58:41.245Z]     checks_out = bindings.check_input_type_annotation(
[2022-05-17T08:58:41.245Z]   File "/opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.4483/workers/python/3.9/OSX/X64/azure_functions_worker/bindings/meta.py", line 44, in check_input_type_annotation
[2022-05-17T08:58:41.245Z]     return binding.check_input_type_annotation(pytype)
[2022-05-17T08:58:41.245Z]   File "/opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.4483/workers/python/3.9/OSX/X64/azure/functions/eventhub.py", line 20, in check_input_type_annotation
[2022-05-17T08:58:41.245Z]     or (isinstance(pytype, type) and issubclass(pytype, valid_types))
[2022-05-17T08:58:41.245Z]   File "/opt/homebrew/Cellar/[email protected]/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/abc.py", line 123, in __subclasscheck__
[2022-05-17T08:58:41.245Z]     return _abc_subclasscheck(cls, subclass)

System info, in case it's relevant:

  • OS - macOS Monterey 12.3.1
  • func --version - 4.0.4483
  • python --version - Python 3.9.12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants