---
source: crates/ruff_linter/src/rules/pyupgrade/mod.rs
---
UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword
 --> UP040.pyi:6:1
  |
4 | # UP040
5 | # Fixes in type stub files should be safe to apply unlike in regular code where runtime behavior could change
6 | x: typing.TypeAlias = int
  | ^^^^^^^^^^^^^^^^^^^^^^^^^
7 | x: TypeAlias = int
  |
help: Use the `type` keyword
  |
5 | # Fixes in type stub files should be safe to apply unlike in regular code where runtime behavior could change
  - x: typing.TypeAlias = int
6 + type x = int
7 | x: TypeAlias = int
  |

UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword
 --> UP040.pyi:7:1
  |
5 | # Fixes in type stub files should be safe to apply unlike in regular code where runtime behavior could change
6 | x: typing.TypeAlias = int
7 | x: TypeAlias = int
  | ^^^^^^^^^^^^^^^^^^
  |
help: Use the `type` keyword
  |
6 | x: typing.TypeAlias = int
  - x: TypeAlias = int
7 + type x = int
8 |
  |

UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword
  --> UP040.pyi:11:1
   |
10 |   # comments in the value are preserved
11 | / x: TypeAlias = tuple[
12 | |     int,  # preserved
13 | |     float,
14 | | ]
   | |_^
15 |
16 |   T: TypeAlias = ( # comment0
   |
help: Use the `type` keyword
   |
10 | # comments in the value are preserved
   - x: TypeAlias = tuple[
11 + type x = tuple[
12 |     int,  # preserved
   |

UP040 [*] Type alias `T` uses `TypeAlias` annotation instead of the `type` keyword
  --> UP040.pyi:16:1
   |
14 |   ]
15 |
16 | / T: TypeAlias = ( # comment0
17 | |     # comment1
18 | |     int  # comment2
19 | |     # comment3
20 | |     | # comment4
21 | |     # comment5
22 | |     str  # comment6
23 | |     # comment7
24 | | ) # comment8
   | |_^
   |
help: Use the `type` keyword
   |
15 |
   - T: TypeAlias = ( # comment0
16 + type T = ( # comment0
17 |     # comment1
   |
