Skip to content

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

@Bibo-Joshi

Description

@Bibo-Joshi

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.

Metadata

Metadata

Assignees

Labels

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions