Prior to Python 3.12 functions using generic types were created as follows:
from typing import TypeVar
_T = TypeVar("_T")
def func(a: _T, b: _T) -> _T:
...
This snippet of code can be confusing and difficult to read. This is why is it a good idea to use the new type parameter syntax of Python 3.12 that
allows for a more concise and more readable code by removing the TypeVar
and its import statement:
def func[T](a: T, b: T) -> T:
...
Exceptions
This rule will only raise an issue when the Python version of the analyzed project is set to 3.12 or higher.