---
source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs
---
PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `NewAny: TypeAlias = Any`
 --> PYI026.pyi:3:1
  |
1 | from typing import Literal, Any
2 |
3 | NewAny = Any
  | ^^^^^^
4 | OptionalStr = typing.Optional[str]
5 | Foo = Literal["foo"]
  |
help: Add `TypeAlias` annotation
  |
1 | from typing import Literal, Any
2 + from typing_extensions import TypeAlias
3 |
  - NewAny = Any
4 + NewAny: TypeAlias = Any
5 | OptionalStr = typing.Optional[str]
  |

PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `OptionalStr: TypeAlias = typing.Optional[str]`
 --> PYI026.pyi:4:1
  |
3 | NewAny = Any
4 | OptionalStr = typing.Optional[str]
  | ^^^^^^^^^^^
5 | Foo = Literal["foo"]
6 | IntOrStr = int | str
  |
help: Add `TypeAlias` annotation
  |
1 | from typing import Literal, Any
2 + from typing_extensions import TypeAlias
3 |
4 | NewAny = Any
  - OptionalStr = typing.Optional[str]
5 + OptionalStr: TypeAlias = typing.Optional[str]
6 | Foo = Literal["foo"]
  |

PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `Foo: TypeAlias = Literal["foo"]`
 --> PYI026.pyi:5:1
  |
3 | NewAny = Any
4 | OptionalStr = typing.Optional[str]
5 | Foo = Literal["foo"]
  | ^^^
6 | IntOrStr = int | str
7 | AliasNone = None
  |
help: Add `TypeAlias` annotation
  |
1 | from typing import Literal, Any
2 + from typing_extensions import TypeAlias
3 |
4 | NewAny = Any
5 | OptionalStr = typing.Optional[str]
  - Foo = Literal["foo"]
6 + Foo: TypeAlias = Literal["foo"]
7 | IntOrStr = int | str
  |

PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `IntOrStr: TypeAlias = int | str`
 --> PYI026.pyi:6:1
  |
4 | OptionalStr = typing.Optional[str]
5 | Foo = Literal["foo"]
6 | IntOrStr = int | str
  | ^^^^^^^^
7 | AliasNone = None
  |
help: Add `TypeAlias` annotation
  |
1 | from typing import Literal, Any
2 + from typing_extensions import TypeAlias
3 |
4 | NewAny = Any
5 | OptionalStr = typing.Optional[str]
6 | Foo = Literal["foo"]
  - IntOrStr = int | str
7 + IntOrStr: TypeAlias = int | str
8 | AliasNone = None
  |

PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `AliasNone: TypeAlias = None`
 --> PYI026.pyi:7:1
  |
5 | Foo = Literal["foo"]
6 | IntOrStr = int | str
7 | AliasNone = None
  | ^^^^^^^^^
8 |
9 | NewAny: typing.TypeAlias = Any
  |
help: Add `TypeAlias` annotation
  |
1 | from typing import Literal, Any
2 + from typing_extensions import TypeAlias
3 |
--------------------------------------------------------------------------------
7 | IntOrStr = int | str
  - AliasNone = None
8 + AliasNone: TypeAlias = None
9 |
  |

PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `FLAG_THIS: TypeAlias = None`
  --> PYI026.pyi:17:5
   |
16 | class NotAnEnum:
17 |     FLAG_THIS = None
   |     ^^^^^^^^^
18 |
19 | # these are ok
   |
help: Add `TypeAlias` annotation
   |
1  | from typing import Literal, Any
2  + from typing_extensions import TypeAlias
3  |
--------------------------------------------------------------------------------
17 | class NotAnEnum:
   -     FLAG_THIS = None
18 +     FLAG_THIS: TypeAlias = None
19 |
   |
