File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -303,10 +303,12 @@ See :ref:`type-narrowing` for more information.
303303Invariance vs covariance
304304------------------------
305305
306- Most mutable generic collections are invariant, and mypy considers all
307- user-defined generic classes invariant by default
308- (see :ref: `variance-of-generics ` for motivation). This could lead to some
309- unexpected errors when combined with type inference. For example:
306+ Most mutable generic collections are invariant. When using the legacy
307+ ``TypeVar `` syntax, mypy considers all user-defined generic classes invariant
308+ by default (see :ref: `variance-of-generics ` for motivation). When using the
309+ :pep: `695 ` syntax (``class MyClass[T]: ... ``), variance is inferred from
310+ usage rather than defaulting to invariant. This could lead to some unexpected
311+ errors when combined with type inference. For example:
310312
311313.. code-block :: python
312314
You can’t perform that action at this time.
0 commit comments