Fix invalid parameter default - #15281
Conversation
|
@cclauss @priya-sundaram-dev I’ve fixed the invalid-parameter-default issues and removed the rule from the ignore list. All checks are passing. Could you please review when you get a chance? Thank you! |
priya-sundaram-dev
left a comment
There was a problem hiding this comment.
Thanks @kadubhumika — nice work, and the code fixes look correct to me:
computer_vision/haralick_descriptors.py:data_type: npt.DTypeLike = np.uint8is the right annotation (np.uint8is a dtype-like class, not anp.dtypeinstance), so the default no longer violates the rule. 👍machine_learning/loss_functions.py:alpha: np.ndarray | None = Noneis exactly the intended fix. 👍
One thing to fix in pyproject.toml before this merges. The diff there is:
-rules.invalid-parameter-default = "ignore"
+rules.invalid-assignment = "ignore"Removing invalid-parameter-default is correct — that's the rule you cleared. But this also re-adds invalid-assignment = "ignore", which isn't on master anymore (it was already cleaned up and removed in an earlier PR). Re-suppressing it silently disables a rule that's currently green.
Could you just delete the invalid-parameter-default line rather than renaming it, so invalid-assignment stays enabled? i.e. the block should read:
rules.invalid-argument-type = "ignore"
rules.invalid-return-type = "ignore"with no invalid-assignment line between them. Checks stay green either way (an added ignore won't fail CI), which is exactly why it's worth catching by eye. Everything else is good to go once that's tidied. 🙌
| rules.deprecated = "ignore" | ||
| rules.invalid-argument-type = "ignore" | ||
| rules.invalid-parameter-default = "ignore" | ||
| rules.invalid-assignment = "ignore" |
There was a problem hiding this comment.
This line needs to be removed.
Always start new pull requests from an up-to-date master branch.
37c5b18 to
52198c6
Compare
priya-sundaram-dev
left a comment
There was a problem hiding this comment.
Thanks @kadubhumika — this is exactly right now. The invalid-parameter-default line is cleanly removed from the ignore list (no other rule silently re-suppressed), and the two fixes are correct:
haralick_descriptors.py:data_type: npt.DTypeLike = np.uint8—np.uint8is a dtype-like class rather than anp.dtypeinstance, sonpt.DTypeLikeis the accurate annotation. 👍loss_functions.py:alpha: np.ndarray | None = None—Nonedefault now matches the type.
ty passes with the rule fully enforced, and ruff/pre-commit are green. Nicely done. LGTM 🎉
Describe your change
Checklist
Summary
Fixed the
invalid-parameter-defaulttype-checking errors.data_typeto usenpt.DTypeLikeincomputer_vision/haralick_descriptors.py.alphato allowNoneinmachine_learning/loss_functions.py.invalid-parameter-defaultignore rule frompyproject.toml.The
invalid-parameter-defaultdiagnostics are now clean.