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. |
MichaReiser
left a comment
There was a problem hiding this comment.
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) |
|
|
||
|
|
||
| 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.
Python noob question: What's the reason for using inline comments here instead of docstrings?
There was a problem hiding this comment.
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.
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.
There was a problem hiding this comment.
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
--diffto 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
blackis 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