Description
Is your feature request related to a problem? Please elaborate.
This issue aims to improve the current state of Modmail's code.
As per the typing standard library docs, many types in the typing
module have been deprecated since Python 3.9 in favor of their built-in counterparts. For example, typing.Tuple
is now deprecated, and tuple
should instead be used for such type annotations.
Furthermore, Python 3.10 and onwards supports the use of the |
operator to define union types. Hence I'm also proposing that typing.Union
and typing.Optional
type annotations are replaced with the |
operator, primarily for the sake of code readability.
To take an example from the project, typing.Tuple[discord.Message, typing.List[typing.Optional[discord.Message]]]
would look like tuple[discord.Message, list[discord.Message | None]]
after the change.
Since the project has recently dropped support for Python versions prior to 3.10, I think that now would be an appropriate time to make these changes. This change intends to make changes exclusively to various type annotations, therefore the bot's functionality and performance will remain unaffected.
Describe the solution you'd like
Import statements that are importing deprecated types from the typing
module would be removed. Type annotations using these deprecated types would be replaced with their built-in counterparts (or the preferred alternative). typing.Union
and typing.Optional
are replaced with the |
operator accordingly.
Changes would include, but are not necessarily limited to:
typing.List
->list
typing.Tuple
->tuple
typing.Optional
andtyping.Union
->... | ...
typing.Sequence
->collections.abc.Sequence
Does your solution involve any of the following?
- Logviewer
- New config option
Describe alternatives you've considered
Nothing to add here.
Who will this benefit?
This change will primarily benefit core developers and maintainers of the project by improving code readability. It may also benefit plugin developers as well as people who are looking to fork the project and make their own changes.
Additional Information
No response