Skip to content

PLW0177 has false negatives for strings that represent NaN #18596

@dscorbett

Description

@dscorbett

Summary

nan-comparison (PLW0177) doesn’t detect float calls that produce NaN if their arguments contain positive or negative signs or white space. Compare verbose-decimal-constructor (FURB157), which does detect them.

$ cat >plw0177.py <<'# EOF'
float("\n+nAn\xA0") == float("-NaN ")
# EOF

$ ruff --isolated check plw0177.py --select PLW0177 --preview
All checks passed!

Version

ruff 0.11.13 (5faf72a 2025-06-05)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedContributions especially welcomeruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions