---
source: crates/ruff_linter/src/rules/pyupgrade/mod.rs
---
--- Linter settings ---
-linter.preview = disabled
+linter.preview = enabled

--- Summary ---
Removed: 2
Added: 2

--- Removed ---
FA100 [*] Add `from __future__ import annotations` to simplify `typing.Optional`
 --> UP045_2.py:5:10
  |
5 | def f(x: Optional[str]) -> None:
  |          ^^^^^^^^
6 |     ...
  |
help: Add `from __future__ import annotations`
  |
1 + from __future__ import annotations
2 | import typing
  |
note: This is an unsafe fix and may change runtime behavior


FA100 [*] Add `from __future__ import annotations` to simplify `typing.Optional`
  --> UP045_2.py:9:10
   |
 9 | def f(x: typing.Optional[str]) -> None:
   |          ^^^^^^^^^^^^^^^
10 |     ...
   |
help: Add `from __future__ import annotations`
  |
1 + from __future__ import annotations
2 | import typing
  |
note: This is an unsafe fix and may change runtime behavior



--- Added ---
UP045 [*] Use `X | None` for type annotations
 --> UP045_2.py:5:10
  |
5 | def f(x: Optional[str]) -> None:
  |          ^^^^^^^^^^^^^
6 |     ...
  |
help: Convert to `X | None`
  |
1 + from __future__ import annotations
2 | import typing
3 | from typing import Optional
4 |
5 |
  - def f(x: Optional[str]) -> None:
6 + def f(x: str | None) -> None:
7 |     ...
  |
note: This is an unsafe fix and may change runtime behavior


UP045 [*] Use `X | None` for type annotations
  --> UP045_2.py:9:10
   |
 9 | def f(x: typing.Optional[str]) -> None:
   |          ^^^^^^^^^^^^^^^^^^^^
10 |     ...
   |
help: Convert to `X | None`
   |
1  + from __future__ import annotations
2  | import typing
--------------------------------------------------------------------------------
9  |
   - def f(x: typing.Optional[str]) -> None:
10 + def f(x: str | None) -> None:
11 |     ...
   |
note: This is an unsafe fix and may change runtime behavior
