-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[ruff
] Add implementation for flake8-markupsafe
via RUF035
#14224
[ruff
] Add implementation for flake8-markupsafe
via RUF035
#14224
Conversation
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
RUF035 | 51 | 51 | 0 | 0 | 0 |
crates/ruff_linter/src/rules/flake8_markupsafe/rules/unsafe_markup_use.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_markupsafe/rules/unsafe_markup_use.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_markupsafe/rules/unsafe_markup_use.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/resources/test/fixtures/flake8_markupsafe/MS001.py
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_markupsafe/rules/unsafe_markup_use.rs
Outdated
Show resolved
Hide resolved
Nice contribution, thanks! |
Lifts fast check out of slow path. Adds additional test cases. Mentions i18n deviation in docstring.
crates/ruff_linter/src/rules/flake8_markupsafe/rules/unsafe_markup_use.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/resources/test/fixtures/flake8_markupsafe/MS001.py
Outdated
Show resolved
Hide resolved
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.
This looks good to me. Thank you. The only change I would make is that I don't think it's worth introducing a new rule group for a single rule.
I'd also like to hear @AlexWaygood's opinion on the rule itself.
crates/ruff_linter/src/rules/flake8_markupsafe/rules/unsafe_markup_use.rs
Outdated
Show resolved
Hide resolved
…rkup_use.rs Co-authored-by: Micha Reiser <[email protected]>
crates/ruff_linter/src/rules/flake8_markupsafe/rules/unsafe_markup_use.rs
Outdated
Show resolved
Hide resolved
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.
I've never used markupsafe
but it makes sense to me that this would be an important security consideration. I think it's good for linters to catch this.
Long-term, we should be able to improve the accuracy of rules like this when we switch to using red-knot as a backend (the LiteralString
type is explicitly designed for this use case). But I don't think that should stop us from implementing this rule now!
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.
Nice!
flake8-markupsafe
] Add implementation for MS001 via RUF035
flake8-markupsafe
] Add implementation for MS001 via RUF035ruff
] Add implementation for flake8-markupsafe
via RUF035
Closes #14124
Summary
This adds an implementation for flake8-markupsafe, minus the questionable exception for i18n and mako support, but with the ability to specify further aliases/subclasses/functionally equivalent for
markupsafe.Markup
. By defaultflask.Markup
is also detected as a commonly used alias.Test Plan
cargo nextest run