Correct. mypy can parse the new syntax, as long as you use Python 3.12 to execute mypy, but it has not yet been updated to understand the semantics behind the new syntax. See https://gh-proxy.deno.dev/python/mypy/issues/15238 for more information on the effort to upgrade mypy.

In the meantime, if you want to use mypy to type-check your code, you cannot use the new syntax. Conversely, if you want to switch to the new syntax, you'll have to use another tool (PyRight, for example) which does support the new syntax.

Answer from chepner on Stack Overflow
🌐
Python documentation
docs.python.org › 3 › whatsnew › 3.12.html
What's New In Python 3.12 — Python 3.14.3 documentation
February 23, 2026 - The new syntax allows declaring TypeVarTuple and ParamSpec parameters, as well as TypeVar parameters with bounds or constraints:
🌐
Python.org
discuss.python.org › typing
TypeVars and the new 3.12 syntax: what happend to co-/contravariances? - Typing - Discussions on Python.org
May 30, 2024 - (Disclaimer: I actually don’t know what “variance” means. I’m writing this post because I’m curious) With the new Python 3.12 we have got a new syntax for TypeVars, so instead of: T = TypeVar("T") def a_fn(arg: T) -> l…
Discussions

Non-uniqueness of TypeVar on Python versions <3.12 causes resolution issues
In Python 3.12, the new Generic / TypeVar syntax allows us to do this: class Foo[T, U]: type: T info: U class Bar[T](Foo[str, T]): test: T Which, for older versions is functionally equivalent to this: fro… More on discuss.python.org
🌐 discuss.python.org
0
October 28, 2023
Should I use a TypeVar?
Typevars are useful if you want to annotate generic classes and function. In your case, you don't need it. More on reddit.com
🌐 r/learnpython
11
7
January 28, 2024
Let's talk about python 3.12's new Type Parameter Syntax.
There was probably much discussion on this placement, and there is not point discussing it now because it won't change. If you want to learn more about this, I recommend reading PEP 695 and additionally the following: https://jellezijlstra.github.io/pep695 https://github.com/python/peps/pull/3122 More on reddit.com
🌐 r/Python
43
0
January 26, 2024
python 3.12 typing override function - Stack Overflow
this type of defining function in python looks a little bit weird to me def override[F: type](method: F, /) -> F:... what is the meaning of [F: type] exactly? is it something like, new way of More on stackoverflow.com
🌐 stackoverflow.com
🌐
Python.org
discuss.python.org › typing
Non-uniqueness of TypeVar on Python versions <3.12 causes resolution issues
October 28, 2023 - In Python 3.12, the new Generic / TypeVar syntax allows us to do this: class Foo[T, U]: type: T info: U class Bar[T](Foo[str, T]): test: T Which, for older versions is functionally equivalent to this: fro…
🌐
Real Python
realpython.com › python312-typing
Python 3.12 Preview: Static Typing Improvements – Real Python
October 21, 2023 - In this tutorial, you'll preview the new static typing features in Python 3.12. You'll learn about the new syntax for type variables, making generics simpler to define. You'll also see how @override lets you model inheritance and how you use typed dictionaries to annotate variable keyword arguments.
🌐
Python
typing.python.org › en › latest › spec › generics.html
Generics — typing documentation
When using the older syntax, the scoping rules are more subtle and complex: A type variable used in a generic function could be inferred to represent different types in the same code block. Example: from typing import TypeVar, Generic T = TypeVar('T') def fun_1(x: T) -> T: ...
🌐
Python documentation
docs.python.org › 3 › library › typing.html
typing — Support for type hints — Python 3.14.3 documentation
1 month ago - from collections.abc import Iterable from typing import TypeVar S = TypeVar("S") Response = Iterable[S] | int · Changed in version 3.7: Generic no longer has a custom metaclass. Changed in version 3.12: Syntactic support for generics and type aliases is new in version 3.12.
Find elsewhere
🌐
ArjanCodes
arjancodes.com › blog › python-generics-syntax
Python 3.12 Generics: Cleaner, Easier Type-Hinting | ArjanCodes
June 6, 2024 - With the new syntax, T, *Ts, and **P replace TypeVar, TypeVarTuple, and ParamSpec, respectively, and any class that has generic annotations is considered a Generic type. This approach uses a more familiar and less cluttered syntax, akin to other programming languages that support generics, making the code more maintainable and understandable. Python 3.12 also simplifies bounding and constraining generic types using a syntax that mirrors type hinting arguments.
🌐
Medium
medium.com › @r_bilan › generics-in-python-3-12-whats-new-in-the-syntax-and-how-to-use-it-now-1024fcdf02f8
Generics in Python 3.12: What’s New in the Syntax and How to Use It Now | by Rostyslav Bilan | Medium
October 2, 2024 - from typing import TypeAlias, TypeVar _T = TypeVar("_T") ListOrSet: TypeAlias = list[_T] | set[_T] But now, with the new syntax in Python 3.12, it can be written as:
🌐
Reddit
reddit.com › r/learnpython › should i use a typevar?
r/learnpython on Reddit: Should I use a TypeVar?
January 28, 2024 -

In my code I have an alias for a type and mypy is happy about it.

NumberedPaths = list[tuple[str, str]]

Should I use TypeVar instead? Is there any better way to define a new type?

🌐
Mypy
mypy.readthedocs.io › en › stable › generics.html
Generics - mypy 1.19.1 documentation
There is also a legacy syntax that relies on TypeVar. Here the number of type arguments must match the number of free type variables in the generic type alias definition. A type variables is free if it’s not a type parameter of a surrounding class or function. Example (following PEP 484: Type aliases, Python 3...
🌐
Python
peps.python.org › pep-0695
PEP 695 – Type Parameter Syntax | peps.python.org
T = 0 # T refers to the global variable print(T) # Prints 0 class Outer[T]: T = 1 # T refers to the local variable scoped to class 'Outer' print(T) # Prints 1 class Inner1: T = 2 # T refers to the local type variable within 'Inner1' print(T) # Prints 2 def inner_method(self): # T refers to the type parameter scoped to class 'Outer'; # If 'Outer' did not use the new type parameter syntax, # this would instead refer to the global variable 'T' print(T) # Prints 'T' def outer_method(self): T = 3 # T refers to the local variable within 'outer_method' print(T) # Prints 3 def inner_func(): # T refers
🌐
Andy Pearce
andy-pearce.com › blog › posts › 2023 › Dec › whats-new-in-python-312-type-hint-improvements
What’s New in Python 3.12 - Type Hint Improvements
December 3, 2023 - Any parameter specifications (ParamSpec that I covered in 3.10) is always invariant. Old-style TypeVar declarations maintain the same semantics, unless you add the new keyword parameter infer_variance=True.
🌐
OneUptime
oneuptime.com › home › blog › how to build generic types with typevar in python
How to Build Generic Types with TypeVar in Python
January 30, 2026 - Python 3.12 introduced a cleaner syntax for generics: # Python 3.11 and earlier from typing import TypeVar, Generic T = TypeVar('T') class OldStack(Generic[T]): def push(self, item: T) -> None: pass def old_first[T](items: list[T]) -> T: ...
🌐
GitHub
github.com › cloudpipe › cloudpickle › issues › 507
Python 3.12: TypeError: cannot create weak reference to 'typing.TypeVar' object · Issue #507 · cloudpipe/cloudpickle
July 3, 2023 - python3.12 -m venv _e . _e/bin/activate pip install -e . pip install -rdev-requirements.txt python -m pytest ... _______________________________________ CloudPickleTest.test_generic_subclass ________________________________________ self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_generic_subclass> def test_generic_subclass(self): T = typing.TypeVar('T') class Base(typing.Generic[T]): pass class DerivedAny(Base): pass class LeafAny(DerivedAny): pass class DerivedInt(Base[int]): pass class LeafInt(DerivedInt): pass class DerivedT(Base[T]): pass class LeafT(DerivedT[T]): pass klasse
Author   musicinmybrain
🌐
GitHub
github.com › python › cpython › issues › 106403
3.12 regression: cannot create weak reference to 'typing.TypeVar' object · Issue #106403 · python/cpython
July 4, 2023 - This works in Python 3.11, but fails in 3.12b3: import weakref import typing weakref.ref(typing.TypeVar('T')) I'm assuming it's an unintentional side effect of the PEP-695 implement...
Author   encukou
🌐
Medium
medium.com › @ggb9898 › python-12-4-features-you-need-to-know-2c441dcf5289
Python 12: 4 Features You Need to Know | by Ggb | Medium
September 21, 2023 - With the new method, there’s no need to import `TypeVar`. Instead, you can simply use the `func[T]` syntax to denote generic type references. Furthermore, it’s possible to specify type bounds, such as determining whether a given type belongs to a particular group of types.
🌐
JetBrains
blog.jetbrains.com › pycharm › 2023 › 11 › python-3-12
Unveiling Python 3.12: What's New in the World of Python? | The PyCharm Blog
TypeVar is a feature of the Python type hinting system that allows you to create a placeholder for a type that will be specified later when a function or class is used. It is primarily used to indicate that a particular type can be of any type, ...
Published   October 16, 2025