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

Annotate method return types with typing.Self where appropriate #759

Merged
merged 2 commits into from
Jan 28, 2025

Conversation

jtrobles-cdd
Copy link
Member

In general, if something returns self, […], you should use Self as the return annotation.

You should not use Self as the return annotation if the method is not guaranteed to return an instance of a subclass when the class is subclassed […]

> The `typing_extensions` module serves two related purposes:
>
> - Enable use of new type system features on older Python versions. […]
> - Enable experimentation with new type system PEPs before they are
>   accepted and added to the `typing` module.

- [Web Site](https://github.com/python/typing_extensions)
- [VCS Repository](https://github.com/python/typing_extensions.git)
- [Documentation](https://typing-extensions.readthedocs.io/)
- [Software Repository](https://pypi.org/project/typing-extensions/)
> In general, if something returns `self`, […], you should use `Self` as
> the return annotation.

> You should not use `Self` as the return annotation if the method is
> not guaranteed to return an instance of a subclass when the class is
> subclassed […]
@jtrobles-cdd jtrobles-cdd added the task Task or chore label Jan 27, 2025
@jtrobles-cdd jtrobles-cdd self-assigned this Jan 27, 2025
@jtrobles-cdd jtrobles-cdd requested a review from a team as a code owner January 27, 2025 22:27
Copy link

codecov bot commented Jan 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.74%. Comparing base (c812fa7) to head (c89f7e0).
Report is 3 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #759      +/-   ##
===========================================
+ Coverage    87.72%   87.74%   +0.01%     
===========================================
  Files           38       38              
  Lines         3145     3149       +4     
  Branches       385      385              
===========================================
+ Hits          2759     2763       +4     
  Misses         245      245              
  Partials       141      141              

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

@jtrobles-cdd jtrobles-cdd merged commit cf35a2b into develop Jan 28, 2025
21 checks passed
@jtrobles-cdd jtrobles-cdd deleted the task/add-typing-self-annotations branch January 28, 2025 13:37
@fpinto-cdd fpinto-cdd mentioned this pull request Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
task Task or chore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants