Skip to content

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

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

Open
DevJake opened this issue Mar 11, 2025 · 1 comment
Labels
enhancement New feature or request P2

Comments

@DevJake
Copy link

DevJake commented Mar 11, 2025

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. feat: Support strongly typed functions signature #208
  2. Document functions_framework.typed #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:

from flask import Request

@functions_framework.http
def main(request: Request):
	pass
from flask import Request

@functions_framework.typed
def main(request: Request):
	pass
@AITechXcel
Copy link

Google has some of the most talented developers and extremely deep pockets and yet somehow this was overlooked. It is not a good look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P2
Projects
None yet
Development

No branches or pull requests

4 participants