Skip to content

refactor(logger): improve typing #3869

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

Merged

Conversation

aminalaee
Copy link
Contributor

@aminalaee aminalaee commented Feb 29, 2024

Issue Number: #3171

Summary

Improve typing of Logger methods: info, 'debug', 'warning', 'critical', ...

The type hints are added per typeshed to avoid any conflicts.

Changes

Please provide a summary of what's being changed

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.

@aminalaee aminalaee requested a review from a team February 29, 2024 14:57
@boring-cyborg boring-cyborg bot added the logger label Feb 29, 2024
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 29, 2024
Copy link

boring-cyborg bot commented Feb 29, 2024

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

@aminalaee aminalaee changed the title Improve Logger method typings fix(logger): improve method typings Feb 29, 2024
@github-actions github-actions bot added the bug Something isn't working label Feb 29, 2024
Copy link
Contributor

No related issues found. Please ensure there is an open issue related to this change to avoid significant delays or closure.

@github-actions github-actions bot added do-not-merge need-issue PRs that are missing related issues labels Feb 29, 2024
@leandrodamascena leandrodamascena linked an issue Feb 29, 2024 that may be closed by this pull request
@leandrodamascena leandrodamascena removed do-not-merge need-issue PRs that are missing related issues labels Feb 29, 2024
@leandrodamascena leandrodamascena changed the title fix(logger): improve method typings refactor(logger): improve method typings Feb 29, 2024
@github-actions github-actions bot added enhancement and removed bug Something isn't working labels Feb 29, 2024
@codecov-commenter
Copy link

codecov-commenter commented Feb 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.38%. Comparing base (e14e768) to head (1a4c478).
Report is 115 commits behind head on develop.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3869   +/-   ##
========================================
  Coverage    96.38%   96.38%           
========================================
  Files          214      214           
  Lines        10030    10109   +79     
  Branches      1846     1868   +22     
========================================
+ Hits          9667     9744   +77     
- Misses         259      261    +2     
  Partials       104      104           

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

@leandrodamascena
Copy link
Contributor

Hello @aminalaee! Thanks for submitting this PR to fix the type annotation issue. For me it's fine and working as expected, but I would like the other maintainers to take a look before merging this.
We hope to merge this early next week and include it in our next release, scheduled for March 8th.

Copy link

sonarqubecloud bot commented Mar 4, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

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

See analysis details on SonarCloud

@rubenfonseca rubenfonseca changed the title refactor(logger): improve method typings refactor(logger): improve typing Mar 4, 2024
@rubenfonseca
Copy link
Contributor

Great job, thank you for adding this!

@rubenfonseca rubenfonseca merged commit 2acfa7d into aws-powertools:develop Mar 4, 2024
Copy link

boring-cyborg bot commented Mar 4, 2024

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

@aminalaee aminalaee deleted the improve-logger-method-typing branch March 4, 2024 10:12
@rafrafek
Copy link
Contributor

Thanks for the PR!

I have found another line causing problems when using Pyright in the strict mode:

Type of "append_keys" is "(**additional_keys: Unknown)

def append_keys(self, **additional_keys) -> None:

Do you know what type it should be annotated?

@leandrodamascena
Copy link
Contributor

Thanks for the PR!

I have found another line causing problems when using Pyright in the strict mode:

Hey @rafrafek! Thanks for your comment. It's often challenging to find comments in closed PRs and issues. For better visibility next time, consider opening a new issue or starting a discussion.

Type of "append_keys" is "(**additional_keys: Unknown)

def append_keys(self, **additional_keys) -> None:

Do you know what type it should be annotated?

If we annotate it as object, Pyright stops complaining.

def append_keys(self, **additional_keys: object) -> None:
    self.registered_formatter.append_keys(**additional_keys)

Do you want to send a PR to fix this? Thanks

@rafrafek
Copy link
Contributor

Hey @leandrodamascena,

I have created #3988 with your suggested changes. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement logger size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typing: Getting type errors on logger usage
5 participants