redundant-none-literal (PYI061)
Derived from the flake8-pyi linter.
Fix is sometimes available.
This rule is unstable and in preview. The --preview
flag is required for use.
What it does
Checks for redundant Literal[None]
annotations.
Why is this bad?
While Literal[None]
is a valid type annotation, it is semantically equivalent to None
.
Prefer None
over Literal[None]
for both consistency and readability.
Example
Use instead:
Fix safety
This rule's fix is marked as safe unless the literal contains comments.