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

docs(examples): enforce and fix all mypy errors #1393

Merged
merged 26 commits into from
Jul 28, 2022

Conversation

heitorlessa
Copy link
Contributor

@heitorlessa heitorlessa commented Jul 28, 2022

Issue number: #1389

Summary

Changes

Please provide a summary of what's being changed

This fixes 50 static typing errors, some customer facing others being mostly due to sentinel values not having a proper typing solution yet.

List of all errors fixed

examples/event_handler_graphql/src/scalar_functions.py:12:1: error: Name "_" already defined on line 11  [no-redef]
examples/event_handler_graphql/src/scalar_functions.py:13:1: error: Name "_" already defined on line 11  [no-redef]
examples/event_handler_graphql/src/scalar_functions.py:14:1: error: Name "_" already defined on line 11  [no-redef]
examples/event_handler_graphql/src/scalar_functions.py:15:1: error: Name "_" already defined on line 11  [no-redef]
examples/tracer/src/sdk_escape_hatch.py:14:10: error: Item "None" of "Optional[BaseProvider]" has no attribute "in_subsegment"  [union-attr]
examples/tracer/src/sdk_escape_hatch.py:14:10: error: Need type annotation for "subsegment"  [var-annotated]
examples/tracer/src/sdk_escape_hatch.py:15:9: error: <nothing> has no attribute "put_annotation"  [attr-defined]
examples/tracer/src/sdk_escape_hatch.py:17:9: error: <nothing> has no attribute "put_metadata"  [attr-defined]
examples/tracer/src/patch_modules.py:1:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/tracer/src/ignore_endpoints.py:3:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/tracer/src/disable_capture_error.py:3:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/logger/src/logging_exceptions.py:1:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/logger/src/append_keys_vs_extra.py:3:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/event_handler_rest/src/split_route_prefix_module.py:1:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/event_handler_rest/src/split_route_module.py:1:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/event_handler_rest/src/setting_cors.py:1:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/event_handler_rest/src/raising_http_errors.py:1:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/event_handler_rest/src/not_found_routes.py:1:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/event_handler_rest/src/http_methods_multiple.py:1:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/event_handler_rest/src/http_methods.py:1:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/event_handler_rest/src/getting_started_rest_api_resolver.py:1:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/event_handler_rest/src/getting_started_http_api_resolver.py:1:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/event_handler_rest/src/getting_started_alb_api_resolver.py:1:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/event_handler_rest/src/fine_grained_responses.py:4:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/event_handler_rest/src/exception_handling.py:1:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/event_handler_rest/src/dynamic_routes.py:1:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/event_handler_rest/src/debug_mode.py:1:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/event_handler_rest/src/custom_serializer.py:5:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/event_handler_rest/src/compressing_responses.py:1:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/event_handler_rest/src/assert_http_response_module.py:1:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/event_handler_rest/src/accessing_request_details_headers.py:1:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/event_handler_rest/src/accessing_request_details.py:3:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/event_handler_graphql/src/getting_started_graphql_api_resolver.py:3:1: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)  [import]
examples/tracer/src/disable_capture_response_streaming_body.py:4:1: error: Skipping analyzing "botocore.response": module is installed, but missing library stubs or py.typed marker  [import]
examples/logger/src/bring_your_own_json_serializer.py:3:1: error: Cannot find implementation or library stub for module named "orjson"  [import]
examples/logger/src/bring_your_own_formatter_from_scratch.py:38:53: error: Missing positional argument "log_record_order" in call to "CustomFormatter"  [call-arg]
examples/event_handler_rest/src/split_route_prefix_module.py:28:20: error: Incompatible types in assignment (expression has type "Optional[str]", variable has type "str")  [assignment]
examples/event_handler_rest/src/split_route_module.py:28:20: error: Incompatible types in assignment (expression has type "Optional[str]", variable has type "str")  [assignment]
examples/event_handler_rest/src/not_found_routes.py:4:1: error: Module "aws_lambda_powertools.event_handler" has no attribute "Response"  [attr-defined]
examples/event_handler_rest/src/fine_grained_responses.py:7:1: error: Module "aws_lambda_powertools.event_handler" has no attribute "Response"  [attr-defined]
examples/event_handler_rest/src/binary_responses.py:14:25: error: Unsupported left operand type for + ("None")  [operator]
examples/event_handler_graphql/src/graphql_transformer_search_merchant.py:36:18: error: Generator has incompatible item type "Merchant"; expected "List[Merchant]"  [misc]
examples/event_handler_graphql/src/graphql_transformer_search_merchant.py:41:1: error: Missing return statement  [return]
examples/event_handler_graphql/src/graphql_transformer_merchant_info.py:35:1: error: Missing return statement  [return]
examples/event_handler_graphql/src/custom_models.py:26:16: error: Incompatible return value type (got "Optional[str]", expected "str")  [return-value]
examples/event_handler_graphql/src/custom_models.py:30:16: error: Incompatible return value type (got "Optional[str]", expected "str")  [return-value]
examples/event_handler_graphql/src/custom_models.py:36:18: error: AppSyncResolverEventT? has no attribute "country_viewer"  [attr-defined]
examples/event_handler_graphql/src/custom_models.py:42:1: error: Missing return statement  [return]
examples/event_handler_graphql/src/assert_async_graphql_response_module.py:29:26: error: Value of type "Coroutine[Any, Any, Any]" is not indexable  [index]
examples/event_handler_graphql/src/assert_async_graphql_response.py:6:1: error: Module "assert_async_graphql_response_module" has no attribute "Location"  [attr-defined]

User experience

Please share what the user experience looks like before and after this change

Checklist

If your change doesn't seem to apply, please leave them unchecked.

Is this a breaking change?

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.


View rendered docs/core/event_handler/api_gateway.md

@heitorlessa heitorlessa requested a review from a team as a code owner July 28, 2022 09:08
@heitorlessa heitorlessa requested review from rubenfonseca and removed request for a team July 28, 2022 09:08
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 28, 2022
@boring-cyborg boring-cyborg bot added dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation event_handlers internal Maintenance changes typing Static typing definition related issues (mypy, pyright, etc.) tracer labels Jul 28, 2022
@heitorlessa heitorlessa changed the title chore(mypy): fix redef _ docs(examples): enforce and fix all mypy errors Jul 28, 2022
@heitorlessa
Copy link
Contributor Author

Looking at the best way to provide up-to-date doc while supporting older Python versions.

@heitorlessa
Copy link
Contributor Author

Related PR #1395 required to merge first otherwise we can't resolve dependencies to proceed with backwards compatible TypedDict

@codecov-commenter
Copy link

Codecov Report

Merging #1393 (0fd0820) into develop (279ba24) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff            @@
##           develop    #1393   +/-   ##
========================================
  Coverage    99.88%   99.88%           
========================================
  Files          119      119           
  Lines         5429     5429           
  Branches       620      620           
========================================
  Hits          5423     5423           
  Misses           2        2           
  Partials         4        4           
Impacted Files Coverage Δ
aws_lambda_powertools/event_handler/appsync.py 100.00% <ø> (ø)
aws_lambda_powertools/event_handler/__init__.py 100.00% <100.00%> (ø)
aws_lambda_powertools/tracing/base.py 100.00% <100.00%> (ø)
aws_lambda_powertools/tracing/tracer.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a0ddd46...0fd0820. Read the comment docs.

@heitorlessa heitorlessa merged commit 723effc into aws-powertools:develop Jul 28, 2022
@heitorlessa heitorlessa deleted the docs/examples-mypy branch July 28, 2022 11:56
heitorlessa added a commit that referenced this pull request Jul 29, 2022
…tools-python into develop

* 'develop' of https://github.com/awslabs/aws-lambda-powertools-python:
  feat(idempotency): handle lambda timeout scenarios for INPROGRESS records (#1387)
  chore(deps): bump jsii from 1.57.0 to 1.63.1 (#1390)
  chore(deps): bump constructs from 10.1.1 to 10.1.59 (#1396)
  chore(deps-dev): bump flake8-isort from 4.1.1 to 4.1.2.post0 (#1384)
  docs(examples): enforce and fix all mypy errors (#1393)
  chore(ci): drop 3.6 from workflows (#1395)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation event_handlers internal Maintenance changes size/L Denotes a PR that changes 100-499 lines, ignoring generated files. typing Static typing definition related issues (mypy, pyright, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants