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

Adopt Py3.8+ features: New Typing features #3735

Closed
Tracked by #3728
Bibo-Joshi opened this issue Jun 2, 2023 · 0 comments
Closed
Tracked by #3728

Adopt Py3.8+ features: New Typing features #3735

Bibo-Joshi opened this issue Jun 2, 2023 · 0 comments
Assignees
Labels
enhancement type hinting Not bug. Not Docs. But both.

Comments

@Bibo-Joshi
Copy link
Member

Python 3.8 adds the

to the typing module. This allows to make some of our type hints more precise.
We should review our code bases and

  • use the @final decorator for classes and methods that should not be subclassed/overridden, e.g. in interface classes like Base{Persistence, Handler, UpdateProcessor, Request}
  • Use Final rather than ClassVar for class attributes that are not supposed to be overridden, e.g. Chat.PRIVATE. Also check if there are other attributes that should be considered final
  • Use Literal where it makes sense. These may be very few places, considering that it does not play well in combination with enums (Literal of enum values python/typing#781)

A PR in this direction is very welcome. As long as #3728 is open, it should be based on the drop-py-37 branch. If you would like to send a PR, please be sure to read our contribution guide and leave a short comment so that we can assign you.

@Bibo-Joshi Bibo-Joshi added enhancement type hinting Not bug. Not Docs. But both. labels Jun 2, 2023
@Bibo-Joshi Bibo-Joshi self-assigned this Jun 12, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jun 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement type hinting Not bug. Not Docs. But both.
Projects
None yet
Development

No branches or pull requests

1 participant