GoogleCloudPlatform / GoogleCloudPlatform/functions-framework-python

Functions defined with `@functions_framework.http` or `@functions_framework.typed` do not support type hints

Đang mở
#361 4 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement P2
Ngôn ngữ chính
Python
Star
968
Fork
128
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Simply put, defining a function with the `@functions_framework.http` decorator does not support type hints. With some digging, I stumbled upon the possibility of using `@functions_framework.typed`, but even this does not work, nor is it documented anywhere. Please see:
1. https://github.com/GoogleCloudPlatform/functions-framework-python/pull/208
2. https://github.com/GoogleCloudPlatform/functions-framework-python/issues/290

This is taken from my attempts to create and deploy a function running python version `3.12.x`. There are no error messages indicating that the cause is the type hints, only that the function failed to be ready and accepting of traffic.

I would suggest the following:
1. Type hints be properly supported for Python functions running any compatible version, given they are now standard practice for developers
2. Versions that use type hinting when they shouldn't -- or otherwise cannot be built -- show an appropriate and relevant error message

As for an example, even the most basic functions such as the following will break:

```python
from flask import Request

@functions_framework.http
def main(request: Request):
pass
```

```python
from flask import Request

@functions_framework.typed
def main(request: Request):
pass
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.