Skip to content

Conversation

robsdedude
Copy link
Contributor

@robsdedude robsdedude commented Jun 11, 2025

Summary

The rule was only detecting more or less straight forward NaN literals (e.g., float("nan")). It'd fail to detect float("+nan") or a little more unhinged float("-NaN\n  \t")

I'd argue this is a fix and not a rule expansion. But I'm not sure you agree. Happy to put this behind a preview flag 🧪

Test Plan

Added the case from the issue + some extra to the tests

Related Issues

Fixes #18596

Copy link
Contributor

github-actions bot commented Jun 11, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@robsdedude robsdedude marked this pull request as ready for review June 11, 2025 17:19
@robsdedude robsdedude marked this pull request as draft June 11, 2025 17:22
@robsdedude robsdedude force-pushed the fix/18596-PLW0177-detect-exotic-nan-literals branch from 2f67a26 to 9a12ddc Compare June 11, 2025 17:52
@robsdedude robsdedude force-pushed the fix/18596-PLW0177-detect-exotic-nan-literals branch from 9a12ddc to 7836c67 Compare June 11, 2025 17:54
@robsdedude robsdedude marked this pull request as ready for review June 11, 2025 18:36
@MichaReiser MichaReiser added the rule Implementing or modifying a lint rule label Jun 19, 2025
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.

Thank you

@MichaReiser MichaReiser enabled auto-merge (squash) June 19, 2025 11:03
@MichaReiser MichaReiser merged commit 4e83db4 into astral-sh:main Jun 19, 2025
32 checks passed
dcreager added a commit that referenced this pull request Jun 19, 2025
* main: (68 commits)
  Unify `OldDiagnostic` and `Message` (#18391)
  [`pylint`] Detect more exotic NaN literals in `PLW0177` (#18630)
  [`flake8-async`] Mark autofix for `ASYNC115` as unsafe if the call expression contains comments (#18753)
  [`flake8-bugbear`] Mark autofix for `B004` as unsafe if the `hasattr` call expr contains comments (#18755)
  Enforce `pytest` import for decorators (#18779)
  [`flake8-comprehension`] Mark autofix for `C420` as unsafe if there's comments inside the dict comprehension (#18768)
  [flake8-async] fix detection for large integer sleep durations in `ASYNC116` rule (#18767)
  Update dependency ruff to v0.12.0 (#18790)
  Update taiki-e/install-action action to v2.53.2 (#18789)
  Add lint rule for calling chmod with non-octal integers (#18541)
  Mark `RET501` fix unsafe if comments are inside (#18780)
  Use `LintContext::report_diagnostic_if_enabled` in `check_tokens` (#18769)
  [UP008]: use `super()`, not `__super__` in error messages (#18743)
  Use Depot Windows runners for `cargo test` (#18754)
  Run ty benchmarks when `ruff_benchmark` changes (#18758)
  Disallow newlines in format specifiers of single quoted f- or t-strings (#18708)
  [ty] Add more benchmarks (#18714)
  [ty] Anchor all exclude patterns (#18685)
  Include changelog reference for other major versions (#18745)
  Use updated pre-commit id (#18718)
  ...
@robsdedude robsdedude deleted the fix/18596-PLW0177-detect-exotic-nan-literals branch June 24, 2025 20:30
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.

PLW0177 has false negatives for strings that represent NaN
2 participants