-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[fastapi] Fix false positive for paths with spaces around parameters (FAST003)
#20077
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
dylwil3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! I think it needs a few tweaks
crates/ruff_linter/src/rules/fastapi/rules/fastapi_unused_path_parameter.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/fastapi/rules/fastapi_unused_path_parameter.rs
Outdated
Show resolved
Hide resolved
|
I recommend making FAST003 only apply to parameters as recognized by FastAPI, instead of just checking for leading and trailing ASCII spaces. |
I think if we avoid the trim then this is basically true (modulo reserved keywords) since we check whether we have an identifier (as pointed out above). So I don't think we need to port the regex over. |
|
I don’t think it is true, even ignoring keywords, but I can open another issue later since it’s not directly related to this one. |
| if param_name.starts_with(' ') || param_name.ends_with(' ') { | ||
| continue; | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we forgot to remove this part
crates/ruff_linter/src/rules/fastapi/rules/fastapi_unused_path_parameter.rs
Outdated
Show resolved
Hide resolved
dylwil3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
…s (`FAST003`) (astral-sh#20077) ## Summary Fixes astral-sh#20060
Summary
Fixes #20060