Skip to content
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

Rename applicability levels to always, sometimes, and never #7821

Merged
merged 5 commits into from
Oct 5, 2023

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Oct 4, 2023

Following much discussion for #4181 at #5119, #5476, #7769, #7819, and in Discord, this pull request changes Applicability from using Automatic, Suggested, and Manual to Always, Sometimes, and Never.

Also removes Applicability::Unspecified (replacing #7792).

@zanieb zanieb changed the title zanie/app refactor freq Refactor applicability to use always / sometimes / never Oct 4, 2023
@zanieb zanieb changed the title Refactor applicability to use always / sometimes / never Rename applicability levels to always, sometimes, and never Oct 4, 2023
@zanieb
Copy link
Member Author

zanieb commented Oct 5, 2023

I'm still not certain these are the best way to express the ideas here, but they are pretty easy to rename in the future and I'd like to move forward to unblock #7769

Applicability::Suggested => "Suggested fix",
Applicability::Manual => "Possible fix",
Applicability::Unspecified => "Suggested fix", /* For backwards compatibility, unspecified fixes are 'suggested' */
// TODO(zanieb): Adjust this messaging once it's user-facing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think is the outcome here? Like what language?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure! Perhaps what I have now with some additional commentary such as the use of --unsafe-fixes to enable the fix.

@@ -365,7 +367,7 @@ pub(crate) fn trailing_commas(
// removing any brackets in the same linter pass - doing both at the same time could
// lead to a syntax error.
let contents = locator.slice(missing_comma.1);
diagnostic.set_fix(Fix::automatic(Edit::range_replacement(
diagnostic.set_fix(Fix::always_applies(Edit::range_replacement(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still prefer Fix::always and Fix::suggested over Fix::always_applies and Fix::sometimes_applies. Isn't the _applies implied?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd then have Fix::always_edits for the multi-edit case which is admittedly strange, but is that why we're including _applies here?

Copy link
Member Author

@zanieb zanieb Oct 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm leaning towards explicit since there was some confusion expressed about the previous methods. I feel like with a bare "always" it's unclear what it refers to and could be confused with the availability?

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 5, 2023

CodSpeed Performance Report

Merging #7821 will degrade performances by 2.49%

Comparing zanie/app-refactor-freq (63d4761) with main (709abd5)

Summary

❌ 1 (👁 1) regressions
✅ 24 untouched benchmarks

Benchmarks breakdown

Benchmark main zanie/app-refactor-freq Change
👁 linter/default-rules[pydantic/types.py] 38 ms 39 ms -2.49%

@github-actions
Copy link
Contributor

github-actions bot commented Oct 5, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

@zanieb zanieb merged commit b64f403 into main Oct 5, 2023
16 checks passed
@zanieb zanieb deleted the zanie/app-refactor-freq branch October 5, 2023 18:43
zanieb added a commit that referenced this pull request Oct 7, 2023
After working with the previous change in
#7821 I found the names a bit
unclear and their relationship with the user-facing API muddied. Since
the applicability is exposed to the user directly in our JSON output, I
think it's important that these names align with our configuration
options. I've replaced `Manual` or `Never` with `Display` which captures
our intent for these fixes (only for display). Here, we create room for
future levels, such as `HasPlaceholders`, which wouldn't fit into the
`Always`/`Sometimes`/`Never` levels.

Unlike #7819, this retains the
flat enum structure which is easier to work with.
konstin pushed a commit that referenced this pull request Oct 11, 2023
Following much discussion for #4181 at
#5119,
#5476, #7769,
#7819, and in
[Discord](https://discord.com/channels/1039017663004942429/1082324250112823306/1159144114231709746),
this pull request changes `Applicability` from using `Automatic`,
`Suggested`, and `Manual` to `Always`, `Sometimes`, and `Never`.

Also removes `Applicability::Unspecified` (replacing #7792).
konstin pushed a commit that referenced this pull request Oct 11, 2023
After working with the previous change in
#7821 I found the names a bit
unclear and their relationship with the user-facing API muddied. Since
the applicability is exposed to the user directly in our JSON output, I
think it's important that these names align with our configuration
options. I've replaced `Manual` or `Never` with `Display` which captures
our intent for these fixes (only for display). Here, we create room for
future levels, such as `HasPlaceholders`, which wouldn't fit into the
`Always`/`Sometimes`/`Never` levels.

Unlike #7819, this retains the
flat enum structure which is easier to work with.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants