Skip to content

fix(typing): make Response headers covariant#3745

Merged
heitorlessa merged 2 commits into
aws-powertools:developfrom
tonnico:fix/response_headers_type
Feb 9, 2024
Merged

fix(typing): make Response headers covariant#3745
heitorlessa merged 2 commits into
aws-powertools:developfrom
tonnico:fix/response_headers_type

Conversation

@tonnico

@tonnico tonnico commented Feb 9, 2024

Copy link
Copy Markdown
Contributor

Issue number: #3743

Summary

Changes

Change typing for headers in Response constructor.

User experience

Able to use covariant of dicts, e.g.

headers_with_str = {"str": "str"}
Response(200, headers=headers_with_str)

headers_with_list = {"str": "str", "list": ["1"]}
Response(200, headers=headers_with_list)

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.

https://docs.python.org/3/library/typing.html#typing.Dict
Note that to annotate arguments, it is preferred to use an abstract collection type such as Mapping rather than to use dict or typing.Dict.
@tonnico tonnico requested a review from a team February 9, 2024 10:16
@boring-cyborg

boring-cyborg Bot commented Feb 9, 2024

Copy link
Copy Markdown

Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

@pull-request-size pull-request-size Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Feb 9, 2024
@codecov-commenter

codecov-commenter commented Feb 9, 2024

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.38%. Comparing base (e14e768) to head (cc7ff50).
⚠️ Report is 2520 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3745   +/-   ##
========================================
  Coverage    96.38%   96.38%           
========================================
  Files          214      214           
  Lines        10030    10030           
  Branches      1846     1846           
========================================
  Hits          9667     9667           
  Misses         259      259           
  Partials       104      104           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud

sonarqubecloud Bot commented Feb 9, 2024

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@heitorlessa heitorlessa changed the title fix(mypy): make Response headers covariant fix(typing): make Response headers covariant Feb 9, 2024
@heitorlessa heitorlessa added the typing Static typing definition related issues (mypy, pyright, etc.) label Feb 9, 2024
@heitorlessa heitorlessa self-assigned this Feb 9, 2024
@heitorlessa

Copy link
Copy Markdown
Contributor

thank you @wurstnase for this quick fix w/ Mapping generic. Everyone appreciates it :)

@heitorlessa heitorlessa merged commit 5dc430c into aws-powertools:develop Feb 9, 2024
@boring-cyborg

boring-cyborg Bot commented Feb 9, 2024

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

event_handlers size/S Denotes a PR that changes 10-29 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