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

ℹ Safe fix
1 1 | from typing import Literal, Any
  2 |+import typing_extensions
2 3 | 
3   |-NewAny = Any
  4 |+NewAny: typing_extensions.TypeAlias = Any
4 5 | OptionalStr = typing.Optional[str]
5 6 | Foo = Literal["foo"]
6 7 | IntOrStr = int | str

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

ℹ Safe fix
1 1 | from typing import Literal, Any
  2 |+import typing_extensions
2 3 | 
3 4 | NewAny = Any
4   |-OptionalStr = typing.Optional[str]
  5 |+OptionalStr: typing_extensions.TypeAlias = typing.Optional[str]
5 6 | Foo = Literal["foo"]
6 7 | IntOrStr = int | str
7 8 | AliasNone = None

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

ℹ Safe fix
1 1 | from typing import Literal, Any
  2 |+import typing_extensions
2 3 | 
3 4 | NewAny = Any
4 5 | OptionalStr = typing.Optional[str]
5   |-Foo = Literal["foo"]
  6 |+Foo: typing_extensions.TypeAlias = Literal["foo"]
6 7 | IntOrStr = int | str
7 8 | AliasNone = None
8 9 | 

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

ℹ Safe fix
1 1 | from typing import Literal, Any
  2 |+import typing_extensions
2 3 | 
3 4 | NewAny = Any
4 5 | OptionalStr = typing.Optional[str]
5 6 | Foo = Literal["foo"]
6   |-IntOrStr = int | str
  7 |+IntOrStr: typing_extensions.TypeAlias = int | str
7 8 | AliasNone = None
8 9 | 
9 10 | NewAny: typing.TypeAlias = Any

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

ℹ Safe fix
1 1 | from typing import Literal, Any
  2 |+import typing_extensions
2 3 | 
3 4 | NewAny = Any
4 5 | OptionalStr = typing.Optional[str]
5 6 | Foo = Literal["foo"]
6 7 | IntOrStr = int | str
7   |-AliasNone = None
  8 |+AliasNone: typing_extensions.TypeAlias = None
8 9 | 
9 10 | NewAny: typing.TypeAlias = Any
10 11 | OptionalStr: TypeAlias = typing.Optional[str]


