mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
Inspection covers such cases: * Extending typing.Generic in new-style generic classes * Extending parameterized typing.Protocol in new-style generic classes * Using generic upper bounds and constraints with type parameters for ParamSpec and TypeVarTuple * Mixing traditional and new-style type variables * Using traditional type variables in new-style type aliases GitOrigin-RevId: 8812959f64d2d87e1b72f713405edb86936220b9
36 lines
1.1 KiB
HTML
36 lines
1.1 KiB
HTML
<html>
|
|
<body>
|
|
<p>Reports invalid usage of <a href="https://www.python.org/dev/peps/pep-0695/">PEP 695</a> type parameter syntax
|
|
<p>
|
|
Finds the following problems in function and class definitions and new-style type alias statements:
|
|
<ul>
|
|
<li>Extending typing.Generic in new-style generic classes</li>
|
|
<li>Extending parameterized typing.Protocol in new-style generic classes</li>
|
|
<li>Using generic upper bounds and constraints with type parameters for ParamSpec and TypeVarTuple</li>
|
|
<li>Mixing traditional and new-style type variables</li>
|
|
<li>Using traditional type variables in new-style type aliases</li>
|
|
</ul>
|
|
|
|
<p>
|
|
Examples:
|
|
</p>
|
|
<pre><code>
|
|
from typing import Generic
|
|
|
|
class Example[T](Generic[T]): ... # Classes with type parameter list should not extend 'Generic'
|
|
</code></pre>
|
|
|
|
<pre><code>
|
|
class Example[T: (list[S], str)]: ... # Generic types are not allowed inside constraints and bounds of type parameters
|
|
</code></pre>
|
|
|
|
<pre><code>
|
|
from typing import TypeVar
|
|
|
|
K = TypeVar("K")
|
|
|
|
class ClassC[V]:
|
|
def method2[M](self, a: M, b: K) -> M | K: ... # Mixing traditional and new-style TypeVars is not allowed
|
|
</code></pre>
|
|
</body>
|
|
</html> |