---
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 |+from typing_extensions import TypeAlias
2 3 | 
3   |-NewAny = Any
  4 |+NewAny: 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 |+from typing_extensions import TypeAlias
2 3 | 
3 4 | NewAny = Any
4   |-OptionalStr = typing.Optional[str]
  5 |+OptionalStr: 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 |+from typing_extensions import TypeAlias
2 3 | 
3 4 | NewAny = Any
4 5 | OptionalStr = typing.Optional[str]
5   |-Foo = Literal["foo"]
  6 |+Foo: 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 |+from typing_extensions import TypeAlias
2 3 | 
3 4 | NewAny = Any
4 5 | OptionalStr = typing.Optional[str]
5 6 | Foo = Literal["foo"]
6   |-IntOrStr = int | str
  7 |+IntOrStr: 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 |+from typing_extensions import TypeAlias
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: TypeAlias = None
8 9 | 
9 10 | NewAny: typing.TypeAlias = Any
10 11 | OptionalStr: TypeAlias = typing.Optional[str]

PYI026.pyi:17:5: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `FLAG_THIS: TypeAlias = None`
   |
16 | class NotAnEnum:
17 |     FLAG_THIS = None
   |     ^^^^^^^^^ PYI026
18 |
19 | # these are ok
   |
   = help: Add `TypeAlias` annotation

ℹ Safe fix
1  1  | from typing import Literal, Any
   2  |+from typing_extensions import TypeAlias
2  3  | 
3  4  | NewAny = Any
4  5  | OptionalStr = typing.Optional[str]
--------------------------------------------------------------------------------
14 15 | AliasNone: typing.TypeAlias = None
15 16 | 
16 17 | class NotAnEnum:
17    |-    FLAG_THIS = None
   18 |+    FLAG_THIS: TypeAlias = None
18 19 | 
19 20 | # these are ok
20 21 | from enum import Enum
