---
source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs
---
PYI061 [*] Use `None` rather than `Literal[None]`
 --> PYI061.pyi:4:25
  |
4 | def func1(arg1: Literal[None]): ...
  |                         ^^^^
  |
help: Replace with `None`
  |
3 |
  - def func1(arg1: Literal[None]): ...
4 + def func1(arg1: None): ...
5 |
  |

PYI061 [*] Use `None` rather than `Literal[None]`
 --> PYI061.pyi:7:25
  |
7 | def func2(arg1: Literal[None] | int): ...
  |                         ^^^^
  |
help: Replace with `None`
  |
6 |
  - def func2(arg1: Literal[None] | int): ...
7 + def func2(arg1: None | int): ...
8 |
  |

PYI061 [*] Use `None` rather than `Literal[None]`
  --> PYI061.pyi:10:24
   |
10 | def func3() -> Literal[None]: ...
   |                        ^^^^
   |
help: Replace with `None`
   |
9  |
   - def func3() -> Literal[None]: ...
10 + def func3() -> None: ...
11 |
   |

PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` 
  --> PYI061.pyi:13:30
   |
13 | def func4(arg1: Literal[int, None, float]): ...
   |                              ^^^^
   |
help: Replace with `Literal[...] | None`
   |
12 |
   - def func4(arg1: Literal[int, None, float]): ...
13 + def func4(arg1: Literal[int, float] | None): ...
14 |
   |

PYI061 [*] Use `None` rather than `Literal[None]`
  --> PYI061.pyi:16:25
   |
16 | def func5(arg1: Literal[None, None]): ...
   |                         ^^^^
   |
help: Replace with `None`
   |
15 |
   - def func5(arg1: Literal[None, None]): ...
16 + def func5(arg1: None): ...
17 |
   |

PYI061 [*] Use `None` rather than `Literal[None]`
  --> PYI061.pyi:16:31
   |
16 | def func5(arg1: Literal[None, None]): ...
   |                               ^^^^
   |
help: Replace with `None`
   |
15 |
   - def func5(arg1: Literal[None, None]): ...
16 + def func5(arg1: None): ...
17 |
   |

PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` 
  --> PYI061.pyi:21:5
   |
19 | def func6(arg1: Literal[
20 |     "hello",
21 |     None  # Comment 1
   |     ^^^^
22 |     , "world"
23 | ]): ...
   |
help: Replace with `Literal[...] | None`
   |
18 |
   - def func6(arg1: Literal[
   -     "hello",
   -     None  # Comment 1
   -     , "world"
   - ]): ...
19 + def func6(arg1: Literal["hello", "world"] | None): ...
20 |
   |
note: This is an unsafe fix and may change runtime behavior

PYI061 [*] Use `None` rather than `Literal[None]`
  --> PYI061.pyi:27:5
   |
26 | def func7(arg1: Literal[
27 |     None  # Comment 1
   |     ^^^^
28 | ]): ...
   |
help: Replace with `None`
   |
25 |
   - def func7(arg1: Literal[
   -     None  # Comment 1
   - ]): ...
26 + def func7(arg1: None): ...
27 |
   |
note: This is an unsafe fix and may change runtime behavior

PYI061 Use `None` rather than `Literal[None]`
  --> PYI061.pyi:31:25
   |
31 | def func8(arg1: Literal[None] | None):...
   |                         ^^^^
   |
help: Replace with `None`

PYI061 [*] Use `None` rather than `Literal[None]`
  --> PYI061.pyi:34:31
   |
34 | def func9(arg1: Union[Literal[None], None]): ...
   |                               ^^^^
   |
help: Replace with `None`
   |
33 |
   - def func9(arg1: Union[Literal[None], None]): ...
34 + def func9(arg1: Union[None, None]): ...
35 |
   |

PYI061 [*] Use `None` rather than `Literal[None]`
  --> PYI061.pyi:42:9
   |
41 | # From flake8-pyi
42 | Literal[None]  # PYI061 None inside "Literal[]" expression. Replace with "None"
   |         ^^^^
43 | Literal[True, None]  # PYI061 None inside "Literal[]" expression. Replace with "Literal[True] | None"
   |
help: Replace with `None`
   |
41 | # From flake8-pyi
   - Literal[None]  # PYI061 None inside "Literal[]" expression. Replace with "None"
42 + None  # PYI061 None inside "Literal[]" expression. Replace with "None"
43 | Literal[True, None]  # PYI061 None inside "Literal[]" expression. Replace with "Literal[True] | None"
   |

PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` 
  --> PYI061.pyi:43:15
   |
41 | # From flake8-pyi
42 | Literal[None]  # PYI061 None inside "Literal[]" expression. Replace with "None"
43 | Literal[True, None]  # PYI061 None inside "Literal[]" expression. Replace with "Literal[True] | None"
   |               ^^^^
   |
help: Replace with `Literal[...] | None`
   |
42 | Literal[None]  # PYI061 None inside "Literal[]" expression. Replace with "None"
   - Literal[True, None]  # PYI061 None inside "Literal[]" expression. Replace with "Literal[True] | None"
43 + Literal[True] | None  # PYI061 None inside "Literal[]" expression. Replace with "Literal[True] | None"
44 |
   |

PYI061 Use `None` rather than `Literal[None]`
  --> PYI061.pyi:47:12
   |
46 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567
47 | x: Literal[None] | None
   |            ^^^^
48 | y: None | Literal[None]
49 | z: Union[Literal[None], None]
   |
help: Replace with `None`

PYI061 Use `None` rather than `Literal[None]`
  --> PYI061.pyi:48:19
   |
46 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567
47 | x: Literal[None] | None
48 | y: None | Literal[None]
   |                   ^^^^
49 | z: Union[Literal[None], None]
   |
help: Replace with `None`

PYI061 [*] Use `None` rather than `Literal[None]`
  --> PYI061.pyi:49:18
   |
47 | x: Literal[None] | None
48 | y: None | Literal[None]
49 | z: Union[Literal[None], None]
   |                  ^^^^
50 |
51 | a: int | Literal[None] | None
   |
help: Replace with `None`
   |
48 | y: None | Literal[None]
   - z: Union[Literal[None], None]
49 + z: Union[None, None]
50 |
   |

PYI061 Use `None` rather than `Literal[None]`
  --> PYI061.pyi:51:18
   |
49 | z: Union[Literal[None], None]
50 |
51 | a: int | Literal[None] | None
   |                  ^^^^
52 | b: None | Literal[None] | None
53 | c: (None | Literal[None]) | None
   |
help: Replace with `None`

PYI061 Use `None` rather than `Literal[None]`
  --> PYI061.pyi:52:19
   |
51 | a: int | Literal[None] | None
52 | b: None | Literal[None] | None
   |                   ^^^^
53 | c: (None | Literal[None]) | None
54 | d: None | (Literal[None] | None)
   |
help: Replace with `None`

PYI061 Use `None` rather than `Literal[None]`
  --> PYI061.pyi:53:20
   |
51 | a: int | Literal[None] | None
52 | b: None | Literal[None] | None
53 | c: (None | Literal[None]) | None
   |                    ^^^^
54 | d: None | (Literal[None] | None)
55 | e: None | ((None | Literal[None]) | None) | None
   |
help: Replace with `None`

PYI061 Use `None` rather than `Literal[None]`
  --> PYI061.pyi:54:20
   |
52 | b: None | Literal[None] | None
53 | c: (None | Literal[None]) | None
54 | d: None | (Literal[None] | None)
   |                    ^^^^
55 | e: None | ((None | Literal[None]) | None) | None
   |
help: Replace with `None`

PYI061 Use `None` rather than `Literal[None]`
  --> PYI061.pyi:55:28
   |
53 | c: (None | Literal[None]) | None
54 | d: None | (Literal[None] | None)
55 | e: None | ((None | Literal[None]) | None) | None
   |                            ^^^^
   |
help: Replace with `None`
