Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flake8-pyi] Implement redundant-none-literal (PYI061) #14316

Merged
merged 9 commits into from
Nov 16, 2024

Conversation

sbrugman
Copy link
Contributor

@sbrugman sbrugman commented Nov 13, 2024

Copy link
Contributor

github-actions bot commented Nov 13, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+14 -0 violations, +0 -0 fixes in 4 projects; 50 projects unchanged)

apache/airflow (+1 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

+ airflow/models/dag.py:1038:36: PYI061 `Literal[None, ...]` can be replaced with `Literal[...] | None`

latchbio/latch (+1 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

+ src/latch/types/metadata.py:500:45: PYI061 `Literal[None, ...]` can be replaced with `Literal[...] | None`

pandas-dev/pandas (+4 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

+ pandas/core/groupby/groupby.py:4069:39: PYI061 `Literal[None, ...]` can be replaced with `Literal[...] | None`
+ pandas/core/groupby/indexing.py:299:39: PYI061 `Literal[None, ...]` can be replaced with `Literal[...] | None`
+ pandas/io/html.py:1027:28: PYI061 `Literal[None, ...]` can be replaced with `Literal[...] | None`
+ pandas/io/html.py:223:32: PYI061 `Literal[None, ...]` can be replaced with `Literal[...] | None`

zulip/zulip (+8 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

+ corporate/views/billing_page.py:326:24: PYI061 `Literal[None, ...]` can be replaced with `Literal[...] | None`
+ corporate/views/remote_billing_page.py:158:26: PYI061 `Literal[None, ...]` can be replaced with `Literal[...] | None`
+ corporate/views/remote_billing_page.py:159:42: PYI061 `Literal[None, ...]` can be replaced with `Literal[...] | None`
+ corporate/views/remote_billing_page.py:160:48: PYI061 `Literal[None, ...]` can be replaced with `Literal[...] | None`
+ corporate/views/remote_billing_page.py:678:26: PYI061 `Literal[None, ...]` can be replaced with `Literal[...] | None`
+ corporate/views/remote_billing_page.py:679:42: PYI061 `Literal[None, ...]` can be replaced with `Literal[...] | None`
+ corporate/views/remote_billing_page.py:680:48: PYI061 `Literal[None, ...]` can be replaced with `Literal[...] | None`
+ corporate/views/remote_billing_page.py:70:5: PYI061 `Literal[None, ...]` can be replaced with `Literal[...] | None`

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
PYI061 14 14 0 0 0

@sbrugman sbrugman marked this pull request as draft November 13, 2024 13:51
@sbrugman sbrugman marked this pull request as ready for review November 13, 2024 14:25
@MichaReiser
Copy link
Member

Hi @sbrugman Thanks for another PR. It would help me review your PRs and avoid unnecessary work if you could fill out the Test plan. E.g. did you review the ecosystem changes already? If so, then I don't have to do so :)

@MichaReiser
Copy link
Member

MichaReiser commented Nov 13, 2024

Is there some previous issue where we discussed this rule? I'm asking because the rule itself would be a better fit for flake8-annotations... except that it isn't an upstream rule

@sbrugman
Copy link
Contributor Author

@MichaReiser I've updated the test plan above, will do so for the other issues as well.

You're right that these rules fit better in another category, but since there is no upstream rule I've placed them here.
I don't think we should hold back on contributing new rules, especially with the new categorisation upcoming.

I'm ok moving the rules if preferred.

@MichaReiser MichaReiser added rule Implementing or modifying a lint rule needs-decision Awaiting a decision from a maintainer preview Related to preview mode features labels Nov 13, 2024
@sbrugman
Copy link
Contributor Author

It looks like this could actually be in flake8-pyi:
https://github.com/PyCQA/flake8-pyi/blob/main/ERRORCODES.md#Y061

@sbrugman sbrugman marked this pull request as draft November 14, 2024 07:32
@sbrugman sbrugman changed the title [ruff] Implement redundant-none-literal (RUF037) [flake8-pyi] Implement redundant-none-literal (PYI061) Nov 14, 2024
@sbrugman sbrugman marked this pull request as ready for review November 14, 2024 07:45
@MichaReiser MichaReiser removed the needs-decision Awaiting a decision from a maintainer label Nov 14, 2024
Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @AlexWaygood could you sign off the rule :)

Comment on lines +96 to +98
if let Some(ref fix) = fix {
diagnostic.set_fix(fix.clone());
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised that setting the same fix works 😆

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! A couple of nitpicks, but looks great overall

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Looks great, just a couple of nits about the test remaining

@charliermarsh charliermarsh enabled auto-merge (squash) November 16, 2024 18:11
@charliermarsh charliermarsh merged commit 78210b1 into astral-sh:main Nov 16, 2024
18 checks passed
dylwil3 pushed a commit to dylwil3/ruff that referenced this pull request Nov 17, 2024
@sbrugman sbrugman deleted the redundant-none-literal branch November 18, 2024 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Related to preview mode features rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants