Python 3.5+

Since Python 3.5 you may use typing module.

Quoting docs, A type alias is defined by assigning the type to the alias:

Copy# Python 3.5-3.8
from typing import List
Vector = List[float]

# Python 3.9+
Vector = list[float] # No import needed, lower case l

To learn more about enforcing types in Python you may want to get familiar with PEPs: PEP483 and PEP484.

Python historically was using duck-typing instead of strong typing and hadn't built-in way of declaring types before 3.5 release.

Answer from Łukasz Rogalski on Stack Overflow
🌐
GitHub
gist.github.com › simonwhitaker › 3a24d669b26b4f373690c6eb113c3ae7
python-type-alias-vs-newtype.md · GitHub
Type aliases are exactly that; simply an alias for a type. Anywhere you refer to the original type (e.g. list[float]), you can now also refer to it as the alias (e.g.
Discussions

Static Enforced Non generic Type alias?
From the pep 484, we have this code (now modernized): type Url = str def retry(url: Url, retry_count: int) -> None: ... But I didn´t find any reference of this aliases should/ are enforced in static analysis. for instance i expect: test: str = 'not_an_url' smght = retry(test) # warning test ... More on discuss.python.org
🌐 discuss.python.org
0
February 6, 2024
Docstrings for new type aliases as defined in PEP 695 - Typing - Discussions on Python.org
Today I’ve started updating to Python 3.12 and adapted my code base to use the new typing aliases defined in PEP 695. Previously, my type was defined as CustomType = dict[str, int] with a docstring below using multine strings. Using the new type alias syntax, this was converted to type CustomType ... More on discuss.python.org
🌐 discuss.python.org
2
October 12, 2023
Help understanding Type Aliases
For the most part, there isn't much of a difference, although the newer syntax should be preferred if you don't plan to support older versions of Python. Basically, type Vector = list[float] is a newer way to write from typing import TypeAlias Vector: TypeAlias = list[float] and for the most part type analysis tools treat Vector = list[float] the same, despite technically containing different types. I think Mypy's documentation explains it better than I can: https://mypy.readthedocs.io/en/stable/kinds_of_types.html#type-aliases More on reddit.com
🌐 r/learnpython
2
3
April 28, 2025
Naming convention for type aliases
The very first example here: https://docs.python.org/3/library/typing.html#type-aliases More on reddit.com
🌐 r/Python
13
8
April 2, 2022
🌐
Python documentation
docs.python.org › 3 › library › typing.html
typing — Support for type hints
1 week ago - Recall that the use of a type alias declares two types to be equivalent to one another. Doing type Alias = Original will make the static type checker treat Alias as being exactly equivalent to Original in all cases.
🌐
Python
peps.python.org › pep-0613
PEP 613 – Explicit Type Aliases | peps.python.org
January 21, 2020 - Type aliases are valid within class scope, both implicitly (x) and explicitly (y). If the line should be interpreted as a class variable, it must be explicitly annotated (z). ... The outer x is a valid type alias, but type checkers must error if the inner x is ever used as a type because type aliases cannot be defined inside of a function.
🌐
Mathspp
mathspp.com › blog › til › type-statement-and-type-aliases
TIL #084 – type statement and type aliases | mathspp
In Python 3.11 and earlier, you'd have to quote the forward references or the self-reference of the first example, like so: from typing import TypeAlias LinkedList: TypeAlias = tuple[int, "LinkedList"] A: TypeAlias = tuple["A", "B", "C"] B: TypeAlias = int C: TypeAlias = str D: TypeAlias = list[str] Type aliases can also be made generic.
🌐
Astral
docs.astral.sh › ruff › rules › type-alias-without-annotation
type-alias-without-annotation (PYI026) | Ruff
Checks for type alias definitions that are not annotated with typing.TypeAlias. In Python, a type alias is defined by assigning a type to a variable (e.g., Vector = list[float]).
Find elsewhere
🌐
Python.org
discuss.python.org › python help
PEP 695 type aliases not suitable as replacement for typing.TypeAlias? - Page 2 - Python Help - Discussions on Python.org
January 18, 2024 - Also to answer this question. I would use explicit aliases and PEP695 aliases in exactly the same way: To give a more succinct, descriptive name to complex type expressions that repeatedly appear in type annotations, it’s also handy for generic unions, to avoid having to repeat the same type parameter over and over again inside a type expression.
🌐
Python
typing.python.org › en › latest › spec › aliases.html
Type aliases — typing documentation
Or by using the type statement (Python 3.12 and higher): type Url = str def retry(url: Url, retry_count: int) -> None: ... Note that we recommend capitalizing alias names, since they represent user-defined types, which (like user-defined classes) are typically spelled that way.
🌐
Real Python
realpython.com › ref › glossary › type-alias
type alias | Python Glossary – Real Python
In Python, a type alias allows you to create an alternative name for an existing type.
🌐
Medium
medium.com › data-science › python-type-hinting-from-type-aliases-to-type-variables-and-new-types-a4a9e0400b6b
Python Type Hinting: From Type Aliases To Type Variables and New Types
April 27, 2023 - The article discusses three type-hinting tools of Python: type aliases, typing.TypeVar (typing variables) and typing.NewType (new types).
🌐
Mypy
mypy.readthedocs.io › en › stable › kinds_of_types.html
Kinds of types - mypy 1.19.1 documentation
It’s just a shorthand notation for another type – it’s equivalent to the target type except for generic aliases. Python 3.12 introduced the type statement for defining explicit type aliases.
🌐
GitHub
github.com › python › typing › discussions › 1850
Mypy: how to use type aliases in generic classes · python/typing · Discussion #1850
August 28, 2024 - For example, T_o_wo is bound to the scope of the type alias T_c_wo and also the class MyDecoCls. At runtime, T_o_wo is the same global object, but a type checker will treat these as completely independent type variables because they have different scopes. If you're using Python 3.12, you may want to switch to the new PEP 695 syntax for defining generics.
Author   python
🌐
Python.org
discuss.python.org › python help
Static Enforced Non generic Type alias? - Python Help - Discussions on Python.org
February 6, 2024 - From the pep 484, we have this code (now modernized): type Url = str def retry(url: Url, retry_count: int) -> None: ... But I didn´t find any reference of this aliases should/ are enforced in static analysis. for instance i expect: test: str = 'not_an_url' smght = retry(test) # warning test = 'not_an_url' smght = retry(test) # maybe no warning based on --strict? test: Url = 'not_an_url' smght = retry(test) # no warning Not sure if this is related with variance / contra-variance, but ...
🌐
Python.org
discuss.python.org › typing
Docstrings for new type aliases as defined in PEP 695 - Typing - Discussions on Python.org
October 12, 2023 - Today I’ve started updating to Python 3.12 and adapted my code base to use the new typing aliases defined in PEP 695. Previously, my type was defined as CustomType = dict[str, int] with a docstring below using multine strings. Using the new type alias syntax, this was converted to type CustomType ...
🌐
Reddit
reddit.com › r/learnpython › help understanding type aliases
r/learnpython on Reddit: Help understanding Type Aliases
April 28, 2025 -

Hi

Im reading through the typing documentation https://docs.python.org/3/library/typing.html and have a question that I cannot answer.

In the past when I wanted to use type aliases I would use code like Vector = list[float] (I think that I must have picked this up from a post on stack overflow or something).

However, in the document above it suggests using the code type Vector = list[float].

The difference between the two is that the data type is types.GenericAlias (the list[float]) for the first Vector and typing.TypeAliasType for the second Vector.

But besides that I am not really sure what is the difference between these two methods. Im not sure where the reason to use one over the other is. Im also not sure where the documntation is for the first example (maybe technically this is not a Type Alias).

Im not sure if anyone can help here?

🌐
Sorokin
sorokin.engineer › posts › en › python_type_aliasing.html
Generic type aliasing in Python
When you use List[Animal] you actually use list with specific items types and without type argument that has its parent, generic list.
🌐
GeeksforGeeks
geeksforgeeks.org › typescript › what-are-type-aliases-and-how-to-create-it-in-typescript
What are type aliases and how to create it in Typescript ? - GeeksforGeeks
July 23, 2025 - Example 2: Implementing type alias in a function. In this example, we will try implementing type alias in a function. We create a type alias called anotherType which is a union of number and string type. The function DisplayId can take arguments that are of type number or string.
🌐
Python.org
discuss.python.org › typing
Run-time behaviour of `TypeAliasType - Page 3 - Typing - Discussions on Python.org
February 2, 2025 - Looks like mypy is expanding the alias in a less useful way, expanding it to overloads of callables… mypy erroring for the above should probably be considered a bug, as should what it infers here. pyright’s matches the obvious for inference: Pyright Playground
🌐
Wikipedia
en.wikipedia.org › wiki › Type_aliasing
Type aliasing - Wikipedia
October 21, 2025 - It does not create a new type hence does not increase type safety. It can be used to shorten a long name. Languages allowing type aliasing include: C++, C# Crystal, D, Dart, Elixir, Elm, F#, Go, Hack, Haskell, Julia, Kotlin, Nim, OCaml, Python, Rust, Scala, Swift and TypeScript.
🌐
Google AI
ai.google.dev › gemini api › models
Models | Gemini API | Google AI for Developers
5 days ago - Points to the latest release for a specific model variation. This can be a stable, preview or experimental release. This alias will get hot-swapped with every new release of a specific model variation.