Skip to content

Comments

[pylint] Also reports case np.nan/case math.nan (PLW0177)#16378

Merged
ntBre merged 4 commits intoastral-sh:mainfrom
InSyncWithFoo:PLW0177
Feb 26, 2025
Merged

[pylint] Also reports case np.nan/case math.nan (PLW0177)#16378
ntBre merged 4 commits intoastral-sh:mainfrom
InSyncWithFoo:PLW0177

Conversation

@InSyncWithFoo
Copy link
Contributor

Summary

Resolves #16374.

PLW0177 now also reports the pattern of a case branch if it is an attribute access whose qualified name is that of either np.nan or math.nan.

As the rule is in preview, the changes are not preview-gated.

Test Plan

cargo nextest run and cargo insta test.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 25, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@ntBre ntBre added the rule Implementing or modifying a lint rule label Feb 25, 2025
@MichaReiser
Copy link
Member

@ntBre could you take a look at this PR?

Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

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

Thanks for your work on this and for the clarification on my match comments! I left a slightly different implementation strategy suggestion for your consideration, but I'm happy with this one too if you are.

Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

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

Nice, thanks!

@ntBre ntBre merged commit 671494a into astral-sh:main Feb 26, 2025
21 checks passed
@InSyncWithFoo InSyncWithFoo deleted the PLW0177 branch February 26, 2025 18:50
dcreager added a commit that referenced this pull request Feb 27, 2025
* main:
  [red-knot] unify LoopState and saved_break_states (#16406)
  [`pylint`] Also reports `case np.nan`/`case math.nan` (`PLW0177`) (#16378)
  [FURB156] Do not consider docstring(s) (#16391)
  Use `is_none_or` in `stdlib-module-shadowing` (#16402)
  [red-knot] Upgrade salsa to include `AtomicPtr` perf improvement (#16398)
  [red-knot] Fix file watching for new non-project files (#16395)
  document MSRV policy (#16384)
  [red-knot] fix non-callable reporting for unions (#16387)
  bump MSRV to 1.83 (#16294)
  Avoid unnecessary info at non-trace server log level (#16389)
  Expand `ruff.configuration` to allow inline config (#16296)
  Start detecting version-related syntax errors in the parser (#16090)
dcreager added a commit that referenced this pull request Feb 27, 2025
* dcreager/dont-have-a-cow:
  [red-knot] unify LoopState and saved_break_states (#16406)
  [`pylint`] Also reports `case np.nan`/`case math.nan` (`PLW0177`) (#16378)
  [FURB156] Do not consider docstring(s) (#16391)
  Use `is_none_or` in `stdlib-module-shadowing` (#16402)
  [red-knot] Upgrade salsa to include `AtomicPtr` perf improvement (#16398)
  [red-knot] Fix file watching for new non-project files (#16395)
  document MSRV policy (#16384)
  [red-knot] fix non-callable reporting for unions (#16387)
  bump MSRV to 1.83 (#16294)
  Avoid unnecessary info at non-trace server log level (#16389)
  Expand `ruff.configuration` to allow inline config (#16296)
  Start detecting version-related syntax errors in the parser (#16090)
dcreager added a commit that referenced this pull request Feb 27, 2025
* main:
  [red-knot] unify LoopState and saved_break_states (#16406)
  [`pylint`] Also reports `case np.nan`/`case math.nan` (`PLW0177`) (#16378)
  [FURB156] Do not consider docstring(s) (#16391)
  Use `is_none_or` in `stdlib-module-shadowing` (#16402)
  [red-knot] Upgrade salsa to include `AtomicPtr` perf improvement (#16398)
  [red-knot] Fix file watching for new non-project files (#16395)
  document MSRV policy (#16384)
  [red-knot] fix non-callable reporting for unions (#16387)
  bump MSRV to 1.83 (#16294)
  Avoid unnecessary info at non-trace server log level (#16389)
  Expand `ruff.configuration` to allow inline config (#16296)
  Start detecting version-related syntax errors in the parser (#16090)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not match-case against np.nan

3 participants