-
-
Notifications
You must be signed in to change notification settings - Fork 351
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
Adopt autoflake
and pyupgrade
formatters
#1059
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1059 +/- ##
==========================================
- Coverage 99.53% 99.53% -0.01%
==========================================
Files 102 102
Lines 12346 12316 -30
Branches 921 922 +1
==========================================
- Hits 12289 12259 -30
Misses 36 36
Partials 21 21
|
Codecov Report
@@ Coverage Diff @@
## master #1059 +/- ##
==========================================
- Coverage 99.53% 99.53% -0.01%
==========================================
Files 102 102
Lines 12346 12316 -30
Branches 921 922 +1
==========================================
- Hits 12289 12259 -30
Misses 36 36
Partials 21 21
|
There's no change in the number of misses, just fewer vacuous hits and I don't think that should be counted as a bad thing |
I like the idea! I also think that we should switch to black to eventually. But I believe the current plan is to get this proposal accepted: https://forum.bors.tech/t/pre-test-and-pre-merge-hooks/322 so that we can do those things automatically without requiring users to install and run more and more autoformatters, which is frustrating when submitting your first PR. (Oh, and I think you need to update docs/source/contributing.rst for this PR to be complete.) |
Sounds great! If others agree, we can take out the bit where this runs in CI, but merge the rest to get most of the benefits - unlike Black, these changes are pretty rare. |
@pquentin - given the CI tooling that we have coming, I've just dropped the CI portion of this PR entirely (beyond comments showing the relevant commands). That leaves us with a one-off application of |
@Zac-HD For the record, I don't know if we should wait for the CI tooling. Progress seems to be slow, and we're only at the Draft RFC step. But, yes, the pull request as it is now is much easier to merge since I don't need to gather consensus on whether it's OK or not to continue adding more manual autoformatters. Thank you! |
In the spirit of #220, here's some development tooling we've adopted in Hypothesis lately for your consideration. I was going to write up an issue, but it seemed easier to explain by example 😉
Both
autoflake
andpyupgrade
aim to canonicalise source code; that is to ensure that equivalent constructs are represented in the same way wherever possible. They also remove some redundancies! For example,autoflake
removes unused (standard library) imports and pointlesspass
statements; whilepyupgrade
standardizes set and dict comprehensions, string formatting, etc.Personally, I've found the enforced consistency does make reading code somewhat easier! If we want to take this further,
isort
andblack
would round it out, but IMO they deserve some discussion first.Thoughts?