-
Notifications
You must be signed in to change notification settings - Fork 429
Code using the event_source decorator fails pyright checks #1085
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
Comments
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
Related to #1060 |
Hi @ericbn, thank you for opening your first issue and flagging a type def to us! As of now, we don't support Pyright but Mypy (non-strict mode) - we had mixed results last year that. When trying so, we found it quite difficult to keep the code maintainable and ensure 100% accuracy due to heavy use of metaprogramming (plus supporting older versions of Python that don't yet have certain mechanisms). I'm changing the label from bug to static_typing. We welcome any targeted solution to this specific type def that also works for 3.6+ as well as Mypy. We had tried some solutions in #1060 but wasn't enough to cover different Python versions and satisfy either Mypy in strict mode as well as Pyright - We do want to revisit it in the future, tho. Thank you! |
Forgot to also thank you for checking upstream. That comment was helpful to understand how much Pyright progressed since we tried early last year, and how we could use that info to improve our existing type def in the future. |
Checking this a year later... apparently Pyright is happy with us now. Nevertheless, I'll go try type the decorator factory as this will help us towards mypy strict which is related. > pyright --verbose
No configuration file found.
pyproject.toml file found at /private/tmp/pyright-test.
Loading pyproject.toml file at /private/tmp/pyright-test/pyproject.toml
No include entries specified; assuming /private/tmp/pyright-test
Auto-excluding **/node_modules
Auto-excluding **/__pycache__
Auto-excluding **/.*
Search paths for /private/tmp/pyright-test/src
/Users/lessa/.cache/pyright-python/1.1.304/node_modules/pyright/dist/typeshed-fallback/stdlib
/private/tmp/pyright-test/src
/private/tmp/pyright-test
/Users/lessa/.cache/pyright-python/1.1.304/node_modules/pyright/dist/typeshed-fallback/stubs/...
/Users/lessa/.pyenv/versions/3.10.11/lib/python3.10
/Users/lessa/.pyenv/versions/3.10.11/lib/python3.10/lib-dynload
/Users/lessa/.pyenv/versions/3.10.11/lib/python3.10/site-packages
Searching for source files
Found 1 source file
pyright 1.1.304
0 errors, 0 warnings, 0 informations
Completed in 0.485sec pyproject.toml [tool.pyright]
pythonPlatform = "Linux"
pythonVersion = "3.9"
stubPath = ""
executionEnvironments = [
{root = "src"},
] src/lambda_function.py import json
from aws_lambda_powertools.utilities.data_classes import event_source, APIGatewayProxyEventV2
@event_source(data_class=APIGatewayProxyEventV2)
def lambda_handler(event: APIGatewayProxyEventV2, context):
return {
"statusCode": 200,
"body": json.dumps({"message": f"hello {event.json_body['name']}!"})
} |
Closing as narrowing types further hits a bug in ParamSpec when using Concatenate in a decorator factory logic: python/mypy#12595. As of now, both mypy and pyright are working (please let us know otherwise). |
|
Uh oh!
There was an error while loading. Please reload this page.
What were you trying to accomplish?
Check code that uses aws_lambda_powertools using pyright.
Expected Behavior
Checking code that correctly uses aws_lambda_powertools should be successful.
Current Behavior
Checking code that uses the
event_source
decorator as documented fails with:Here's the code used:
Other types might be affected too. Here's the output when pyright with the special option "--verifytypes" is called on aws_lambda_powertools:
This means about 17% of the symbols exposed are not properly annotated.
See this comment here.
Possible Solution
Complete the type annotations.
Steps to Reproduce (for bugs)
Environment
N/A
The text was updated successfully, but these errors were encountered: