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

fix(tracer): mypy generic to preserve decorated method signature #529

Conversation

heitorlessa
Copy link
Contributor

@heitorlessa heitorlessa commented Jul 16, 2021

Issue #, if available: #465

Description of changes:

Checklist

Breaking change checklist

RFC issue #:

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

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

@codecov-commenter
Copy link

codecov-commenter commented Jul 16, 2021

Codecov Report

Merging #529 (8e1b352) into develop (5b87bb1) will decrease coverage by 0.04%.
The diff coverage is 83.33%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #529      +/-   ##
===========================================
- Coverage    99.23%   99.19%   -0.05%     
===========================================
  Files          113      113              
  Lines         4468     4476       +8     
  Branches       243      243              
===========================================
+ Hits          4434     4440       +6     
- Misses          22       24       +2     
  Partials        12       12              
Impacted Files Coverage Δ
aws_lambda_powertools/tracing/tracer.py 98.95% <83.33%> (-1.05%) ⬇️

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 5b87bb1...8e1b352. Read the comment docs.

@heitorlessa
Copy link
Contributor Author

Limitation: Async functions signature for type checking can only be preserved by using ParamSpec introduced in 3.10 - PEP 612

We could bring typing_extensions module (240K) which also brings other fixes we'll likely encounter as we adopt mypy more broadly in this lib, including nice features like Protocol for interfaces.

I'll postpone bringing typing_extensions until we either a) hear directly from customers using mypy with async fn as this will manifest elsewhere too not just Powertools, or b) find that we need typing_extensions in order to resolve current mypy findings someplace else.

cc @michaelbrewer @pcolazurdo @cakepietoast

@heitorlessa heitorlessa added internal Maintenance changes bug Something isn't working and removed internal Maintenance changes labels Jul 17, 2021
@heitorlessa heitorlessa marked this pull request as ready for review July 17, 2021 12:45
@heitorlessa heitorlessa added this to the 1.18.0 milestone Jul 17, 2021
@heitorlessa heitorlessa changed the title fix(tracer): mypy use generic type to preserve decorated method signature fix(tracer): mypy generic to preserve decorated method signature Jul 17, 2021
@heitorlessa heitorlessa merged commit d5c3431 into aws-powertools:develop Jul 17, 2021
@heitorlessa heitorlessa deleted the fix/tracer-decorator-correctness branch July 17, 2021 12:46
heitorlessa added a commit to heitorlessa/aws-lambda-powertools-python that referenced this pull request Jul 17, 2021
* develop:
  chore(deps): bump boto3 from 1.18.0 to 1.18.1 (aws-powertools#528)
  fix(tracer): mypy generic to preserve decorated method signature (aws-powertools#529)
  fix(parser): Make ApiGateway version, authorizer fields optional (aws-powertools#532)
  fix(mypy): fixes to resolve no implicit optional errors (aws-powertools#521)
  chore(deps): bump boto3 from 1.17.110 to 1.18.0 (aws-powertools#527)
  feat(feat-toggle): New simple feature toggles rule engine (WIP) (aws-powertools#494)
  chore(deps-dev): bump mkdocs-material from 7.1.9 to 7.1.10 (aws-powertools#522)
  chore(deps): bump boto3 from 1.17.102 to 1.17.110 (aws-powertools#523)
  chore(deps-dev): bump isort from 5.9.1 to 5.9.2 (aws-powertools#514)
  feat(mypy): add mypy support to makefile (aws-powertools#508)
  feat(api-gateway): add debug mode (aws-powertools#507)
heitorlessa added a commit to whardier/aws-lambda-powertools-python that referenced this pull request Jul 19, 2021
…ent-subclass

* develop:
  fix(api-gateway): non-greedy route pattern regex (aws-powertools#533)
  chore(deps): bump boto3 from 1.18.0 to 1.18.1 (aws-powertools#528)
  fix(tracer): mypy generic to preserve decorated method signature (aws-powertools#529)
  fix(parser): Make ApiGateway version, authorizer fields optional (aws-powertools#532)
  fix(mypy): fixes to resolve no implicit optional errors (aws-powertools#521)
  chore(deps): bump boto3 from 1.17.110 to 1.18.0 (aws-powertools#527)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants