-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add new ecosystem comparison modes for the formatter #8416
Conversation
f7b5fd0
to
18b8873
Compare
PR Check ResultsEcosystem✅ ecosystem check detected no linter changes. ✅ ecosystem check detected no format changes. |
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. I love the different modes for running it locally
case FormatComparison.black_then_ruff: | ||
coro = format_then_format(Formatter.black, *args) | ||
case FormatComparison.black_and_ruff: | ||
coro = format_and_format(Formatter.black, *args) |
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.
Oh that's cool
|
||
|
||
class FormatComparison(Enum): | ||
# Run Ruff baseline then Ruff comparison; checks for changes in behavior when formatting previously "formatted" code |
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.
Python noob question: What's the reason for using inline comments here instead of docstrings?
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 don't think there's a formalized way to document class attributes individually. Generally what you do is create a class docstring and then document the members using an 'Attributes' section, but that felt like more work than I wanted to do here 😬
tldr a docstring for the class is proper but I was lazy. I wish we had tooling to generate the scaffold.
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 even just wrote it out and it feels awkward; I guess I write Rust now
class FormatComparison(Enum):
"""
The type of format comparison to use.
Attributes:
ruff_then_ruff: Run Ruff baseline then Ruff comparison; checks for changes in
behavior when formatting previously "formatted" code
ruff_and_ruff: Run Ruff baseline then reset and run Ruff comparison; checks
changes in behavior when formatting "unformatted" code
black_then_ruff: Run Black baseline then Ruff comparison; checks for changes in
behavior when formatting previously "formatted" code
black_and_ruff: Run Black baseline then reset and run Ruff comparison; checks
changes in behavior when formatting "unformatted" code
"""
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.
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.
Since you nudged, I switched to individual attribute docstrings — while the PEP is rejected, VSCode supports it.
82c8405
to
eef3b25
Compare
Extends #8416 activating the `black-and-ruff` and `black-then-ruff` formatter comparison modes for ecosystem checks allowing us to compare changes to Black across the ecosystem.
Previously, the ecosystem checks formatted with the baseline then formatted again with
--diff
to get the changed files.Now, the ecosystem checks support a new mode where we:
This effectively tests Ruff changes on unformatted code rather than changes in previously formatted code (unless, of course, the project is already using Ruff).
While this mode is the new default, I've retained the old one for local checks. The mode can be toggled with
--format-comparison <type>
.Includes some more aggressive resetting of the GitHub repositories when cached.
Here, I've also stubbed comparison modes in which
black
is used as the baseline. While these do nothing here, #8419 adds support.I tested this with the commit from #8216 and ecosystem changes appear https://gist.github.com/zanieb/a982ec8c392939043613267474471a6e