Skip to content

Add more ruff rules #4001

Open
Open

Description

@dopplershift

Add more rules to our ruff config. Current ones I'm seeing:

  • Pathlib PTH
  • Pytest style PT
  • PyLint PL

A brief check shows some things I'd want to look into with the first two. Pylint will need to be more judicious, since a brief look seems to show some things I don't care to fix (overwriting loop variables). That said, I also just saw this while writing:

PLW0177 Comparing against a NaN value; use `math.isnan` instead
    --> src/metpy/io/gempak.py:2599:12
     |
2598 |         station['TIME'] = parsed.date_time.time()
2599 |         if math.nan in [parsed.altimeter, parsed.elevation, parsed.temperature]:
     |            ^^^^^^^^
2600 |             station['PMSL'] = missing
2601 |         else:
     |

which is suspicious but somehow isn't a bug, though should be changed anyways:

import math

a = [1, 1.1, math.nan]

math.nan in a

True

Activity

  1. dopplershift commented on Feb 12, 2026

    @dopplershift
    MemberAuthor

    Ok, based on this post it seems to be that is is getting the nan check above to work. But if you change the source of nan (since IEEE-754 defines many nans that differ bit-wise), you can get it to fail:

    import math
    
    a = [1, 1.1, float('nan')]
    
    math.nan in a

    False

    So the issue found by the PLW rule above is definitely a bug that should be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: InfrastructurePertains to project infrastructure (e.g. CI, linting)Type: EnhancementEnhancement to existing functionality

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions