azure-functions-python-worker
azure-functions-python-worker copied to clipboard
[FeatureRequest] Support Python 3.9 style hinting using standard collections per PEP 585
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