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

Merge Availability and AutofixKind #3629

Merged

Conversation

JonathanPlasse
Copy link
Contributor

Implement suggestion from @MichaReiser

NIt: Unrelated to this change: A Availability::None would remove the need for Option<AutofixKind>. It would then simply be AUTOFX: AutofixKind = AutofixKind::NONE (we could even inline Availability into AutofixKind

Originally posted by @MichaReiser in #3593 (comment)

Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

Nice. Thanks for working on this improvement :)

Comment on lines 35 to 47
match rule.autofixable() {
AutofixKind::Sometimes => {
output.push_str("Autofix is sometimes available.");
output.push('\n');
output.push('\n');
}
AutofixKind::Always => {
output.push_str("Autofix is always available.");
output.push('\n');
output.push('\n');
}
AutofixKind::None => {}
}
Copy link
Member

Choose a reason for hiding this comment

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

Nit: We could implement Display for AutofixKind. You could then write this as

Suggested change
match rule.autofixable() {
AutofixKind::Sometimes => {
output.push_str("Autofix is sometimes available.");
output.push('\n');
output.push('\n');
}
AutofixKind::Always => {
output.push_str("Autofix is always available.");
output.push('\n');
output.push('\n');
}
AutofixKind::None => {}
}
let autofix = rule.autofixable();
if matches!(autofix, AutofxKind::Sometimes | AutofixKind::Always) {
writeln!(output, "{autofix}\n").unwrap(); // Writting to a string never fails except if the program OOms
}

and then re-use the same logic in generate_docs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not know the term OOms. What does it mean?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, sorry. I should avoid using acronyms, and that's my java background shining through. OOM is an acronym for Out of Memory (exception in Java). And OOms is the activity when the program runs out of memory. The equivalent in Python is probably the MemoryError

@github-actions
Copy link
Contributor

github-actions bot commented Mar 20, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

Benchmark

Linux

group                                      main                                   pr
-----                                      ----                                   --
linter/all-rules/large/dataset.py          1.00     14.2±0.05ms     2.9 MB/sec    1.00     14.1±0.07ms     2.9 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.01      3.7±0.01ms     4.4 MB/sec    1.00      3.7±0.01ms     4.5 MB/sec
linter/all-rules/numpy/globals.py          1.00    427.3±2.45µs     6.9 MB/sec    1.00    425.3±1.98µs     6.9 MB/sec
linter/all-rules/pydantic/types.py         1.00      6.3±0.01ms     4.1 MB/sec    1.00      6.3±0.01ms     4.1 MB/sec
linter/default-rules/large/dataset.py      1.01      7.8±0.02ms     5.2 MB/sec    1.00      7.7±0.02ms     5.3 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.00   1689.1±5.22µs     9.9 MB/sec    1.00   1692.6±4.20µs     9.8 MB/sec
linter/default-rules/numpy/globals.py      1.00    175.3±0.33µs    16.8 MB/sec    1.01    176.5±0.64µs    16.7 MB/sec
linter/default-rules/pydantic/types.py     1.00      3.6±0.01ms     7.0 MB/sec    1.00      3.6±0.00ms     7.0 MB/sec

Windows

group                                      main                                   pr
-----                                      ----                                   --
linter/all-rules/large/dataset.py          1.00     14.7±0.12ms     2.8 MB/sec    1.00     14.8±0.20ms     2.7 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.00      4.0±0.02ms     4.1 MB/sec    1.02      4.1±0.10ms     4.1 MB/sec
linter/all-rules/numpy/globals.py          1.00    428.8±6.69µs     6.9 MB/sec    1.00    430.8±6.15µs     6.8 MB/sec
linter/all-rules/pydantic/types.py         1.00      6.6±0.07ms     3.9 MB/sec    1.03      6.8±0.18ms     3.8 MB/sec
linter/default-rules/large/dataset.py      1.00      8.1±0.03ms     5.0 MB/sec    1.01      8.2±0.07ms     5.0 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.00   1722.6±7.38µs     9.7 MB/sec    1.01  1733.8±12.06µs     9.6 MB/sec
linter/default-rules/numpy/globals.py      1.00    172.4±1.73µs    17.1 MB/sec    1.01    173.6±2.02µs    17.0 MB/sec
linter/default-rules/pydantic/types.py     1.00      3.7±0.02ms     6.8 MB/sec    1.00      3.7±0.01ms     6.8 MB/sec

@JonathanPlasse JonathanPlasse force-pushed the merge-availablity-and-autofixkind branch from 851a8ae to 49fcccc Compare March 20, 2023 16:39
@MichaReiser MichaReiser enabled auto-merge (squash) March 20, 2023 16:44
@MichaReiser MichaReiser merged commit fd39ec4 into astral-sh:main Mar 20, 2023
@JonathanPlasse JonathanPlasse deleted the merge-availablity-and-autofixkind branch March 20, 2023 16:45
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.

None yet

2 participants