[ruff] Make fix for implicit-optional (RUF013) safe in preview#17836
Closed
dylwil3 wants to merge 3 commits intoastral-sh:mainfrom
Closed
[ruff] Make fix for implicit-optional (RUF013) safe in preview#17836dylwil3 wants to merge 3 commits intoastral-sh:mainfrom
ruff] Make fix for implicit-optional (RUF013) safe in preview#17836dylwil3 wants to merge 3 commits intoastral-sh:mainfrom
Conversation
Contributor
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| RUF013 | 62 | 0 | 0 | 62 | 0 |
MichaReiser
reviewed
May 5, 2025
| } | ||
|
|
||
| // https://github.com/astral-sh/ruff/pull/17836 | ||
| pub(crate) const fn is_implicit_optional_fix_safe(settings: &LinterSettings) -> bool { |
Member
There was a problem hiding this comment.
It would be nice if we can keep the _postfix. It helps readers to easily recognize this as a preview check
Member
|
I think the reason why the fix is unsafe is because it's a possibility that the default value is wrong (a leftover from changing the signature from |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The fix for implicit-optional (RUF013), introduced in #4831, was marked as unsafe, but I can't actually see a reason why it would be. So this PR makes the fix safe when
previewis enabled.Some potential reasons why it is marked as unsafe:
Optional- but we usetry_set_fixto abort if that wasn't possible for some reason.But it's possible I'm missing something here so please let me know!