-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
ruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
Summary
numpy's not-a-number (np.nan) will never be matched in a match-case statement. But neither ruff nor mypy complain.
The following prints out Found a number: nan, because np.nan does not match with np.nan.
import numpy as np
def my_func(number: float) -> None:
match number:
case np.nan:
print("Found np.nan")
case float(number):
print(f"Found a number: {number}")
my_func(np.nan)
I believe using np.nan in a match-case statement should be considered a mistake and it would be cool to have a rule as part of the numpy-specific-rules
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
ruleImplementing or modifying a lint ruleImplementing or modifying a lint rule