ruff/crates/ruff_python_semantic/src
Robsdedude 6802c4702f
[`flake8-pyi`] Expand `Optional[A]` to `A | None` (`PYI016`) (#18572)
## Summary
Under preview 🧪 I've expanded rule `PYI016` to also flag type
union duplicates containing `None` and `Optional`.

## Test Plan
Examples/tests have been added. I've made sure that the existing
examples did not change unless preview is enabled.

## Relevant Issues
* https://github.com/astral-sh/ruff/issues/18508 (discussing
introducing/extending a rule to flag `Optional[None]`)
* https://github.com/astral-sh/ruff/issues/18546 (where I discussed this
addition with @AlexWaygood)

---------

Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com>
Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com>
2025-06-27 15:43:11 +00:00
..
analyze [`flake8-pyi`] Expand `Optional[A]` to `A | None` (`PYI016`) (#18572) 2025-06-27 15:43:11 +00:00
cfg Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
model [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
binding.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
branches.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
context.rs Remove separate `ReferenceContext` enum (#4631) 2023-05-24 15:12:38 +00:00
definition.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
globals.rs [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
imports.rs [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
lib.rs Control flow graph: setup (#17064) 2025-04-01 05:53:42 -05:00
model.rs [`flake8-pyi`] Expand `Optional[A]` to `A | None` (`PYI016`) (#18572) 2025-06-27 15:43:11 +00:00
nodes.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
reference.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
scope.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
star_import.rs Make ImportFrom level just a u32 (#11170) 2024-04-26 20:38:35 -06:00