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

[fmt] Add CI step for black (and remove darker) #4725

Merged
merged 2 commits into from
Oct 15, 2024

Conversation

RMeli
Copy link
Member

@RMeli RMeli commented Oct 2, 2024

Add black (version 24) to CI, and start formatting two files: tables.py and due.py. This showcases hot to incrementally add files to the black configuration, and how to turn off automated formatting in some portions of tables.py.

This PR also removes darken.

Developers certificate of origin


📚 Documentation preview 📚: https://mdanalysis--4725.org.readthedocs.build/en/4725/

@RMeli
Copy link
Member Author

RMeli commented Oct 2, 2024

Copy link

codecov bot commented Oct 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.58%. Comparing base (599c8db) to head (faffd70).
Report is 61 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4725      +/-   ##
===========================================
- Coverage    93.60%   93.58%   -0.03%     
===========================================
  Files          173      185      +12     
  Lines        21463    22530    +1067     
  Branches      2993     2993              
===========================================
+ Hits         20090    21084     +994     
- Misses         929     1002      +73     
  Partials       444      444              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pep8speaks
Copy link

pep8speaks commented Oct 2, 2024

Hello @RMeli! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 384:80: E501 line too long (89 > 79 characters)
Line 385:80: E501 line too long (89 > 79 characters)
Line 386:80: E501 line too long (89 > 79 characters)
Line 387:80: E501 line too long (89 > 79 characters)
Line 388:80: E501 line too long (89 > 79 characters)
Line 389:80: E501 line too long (89 > 79 characters)
Line 390:80: E501 line too long (89 > 79 characters)
Line 391:80: E501 line too long (89 > 79 characters)
Line 392:80: E501 line too long (89 > 79 characters)
Line 393:80: E501 line too long (88 > 79 characters)
Line 394:80: E501 line too long (89 > 79 characters)
Line 395:80: E501 line too long (89 > 79 characters)
Line 396:80: E501 line too long (89 > 79 characters)
Line 397:80: E501 line too long (85 > 79 characters)
Line 398:80: E501 line too long (86 > 79 characters)

Comment last updated at 2024-10-14 19:23:05 UTC

Comment on lines +384 to +398
Z2SYMB = {1: 'H', 2: 'He',
3: 'Li', 4: 'Be', 5: 'B', 6: 'C', 7: 'N', 8: 'O', 9: 'F', 10: 'Ne',
11: 'Na', 12: 'Mg', 13: 'Al', 14: 'Si', 15: 'P', 16: 'S', 17: 'Cl', 18: 'Ar',
19: 'K', 20: 'Ca', 21: 'Sc', 22: 'Ti', 23: 'V', 24: 'Cr', 25: 'Mn', 26: 'Fe',
27: 'Co', 28: 'Ni', 29: 'Cu', 30: 'Zn', 31: 'Ga', 32: 'Ge', 33: 'As', 34: 'Se',
35: 'Br', 36: 'Kr', 37: 'Rb', 38: 'Sr', 39: 'Y', 40: 'Zr', 41: 'Nb', 42: 'Mo',
43: 'Tc', 44: 'Ru', 45: 'Rh', 46: 'Pd', 47: 'Ag', 48: 'Cd', 49: 'In', 50: 'Sn',
51: 'Sb', 52: 'Te', 53: 'I', 54: 'Xe', 55: 'Cs', 56: 'Ba', 57: 'La', 58: 'Ce',
59: 'Pr', 60: 'Nd', 61: 'Pm', 62: 'Sm', 63: 'Eu', 64: 'Gd', 65: 'Tb', 66: 'Dy',
67: 'Ho', 68: 'Er', 69: 'Tm', 70: 'Yb', 71: 'Lu', 72: 'Hf', 73: 'Ta', 74: 'W',
75: 'Re', 76: 'Os', 77: 'Ir', 78: 'Pt', 79: 'Au', 80: 'Hg', 81: 'Tl', 82: 'Pb',
83: 'Bi', 84: 'Po', 85: 'At', 86: 'Rn', 87: 'Fr', 88: 'Ra', 89: 'Ac', 90: 'Th',
91: 'Pa', 92: 'U', 93: 'Np', 94: 'Pu', 95: 'Am', 96: 'Cm', 97: 'Bk', 98: 'Cf',
99: 'Es', 100: 'Fm', 101: 'Md', 102: 'No', 103: 'Lr', 104: 'Rf', 105: 'Db',
106: 'Sg', 107: 'Bh', 108: 'Hs', 109: 'Mt', 110: 'Ds', 111: 'Rg', 112: 'Cn',
Copy link
Member Author

Choose a reason for hiding this comment

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

Here the automated formatting is off, but I manually removed trailing whitespaces (hence the diff).

Comment on lines +128 to +134
include = '''
(
tables\.py
| due\.py
)
'''
Copy link
Member Author

Choose a reason for hiding this comment

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

Let's start simple, with only two files. Other files or matching regexp can be added with the | operator.

@RMeli RMeli requested review from IAlibay and marinegor October 2, 2024 21:24
@RMeli
Copy link
Member Author

RMeli commented Oct 2, 2024

@RMeli RMeli marked this pull request as ready for review October 3, 2024 11:41
Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

lgtm!

@RMeli
Copy link
Member Author

RMeli commented Oct 3, 2024

This PR now contains only 3 commits, and should not be squash-merged:

  • ee6cbd1 enables black in CI and cleans up darker
  • feca121 formats due.py and tables.py
  • ae05db7 adds the previous commit to .git-blame-ignore-revs, so that git blame will point to the original author

The latter is the reason why the PR should not be squash-merged.

@RMeli RMeli requested a review from IAlibay October 3, 2024 20:03
@RMeli RMeli marked this pull request as ready for review October 3, 2024 20:04
@orbeckst
Copy link
Member

orbeckst commented Oct 7, 2024

@IAlibay can you please shepherd the PR as you're a reviewer and it changes the CI?

@orbeckst
Copy link
Member

orbeckst commented Oct 7, 2024

@RMeli can you please resolve conflicts?

@RMeli
Copy link
Member Author

RMeli commented Oct 7, 2024

@orbeckst I don't see the conflicts, two are files being deleted... I think GitHub might have been confused by my mess with my rebasing + cherry piking commits + force pushing.

@orbeckst
Copy link
Member

orbeckst commented Oct 7, 2024

This is what it looks like to me:
image

At least I couldn't merge from the GH interface.

@RMeli
Copy link
Member Author

RMeli commented Oct 7, 2024

Yes, it looks the same for me, but locally I was unable to see any conflict. I think I also rebased develop, but I'll try again later. Worst case I'll close this PR and open a new one with the commits cherry picked.

@RMeli RMeli closed this Oct 7, 2024
@RMeli RMeli reopened this Oct 7, 2024
@RMeli
Copy link
Member Author

RMeli commented Oct 11, 2024

I really don't know what is going on here... I just created a new branch from develop, cherry picked the three commits mentioned above, hard-reset this branch to the new branch, and force-pushed.

If I rebase develop, it says this is up to date. Same with merge.

@IAlibay
Copy link
Member

IAlibay commented Oct 13, 2024

@RMeli I fixed the merge conflict, but that added two commits - can you check if the commit history needs cleaning up or if it's still good to non-squash merge?

@RMeli
Copy link
Member Author

RMeli commented Oct 13, 2024

Thanks @IAlibay. I see a merge commit from develop (strange, for me it did not work…), which would be better not to have in the develop branch. I’m try to squash a few commits.

@IAlibay
Copy link
Member

IAlibay commented Oct 13, 2024

which would be better not to have in the develop branch

I mean for the odd occasion I think we can live with it.

@RMeli
Copy link
Member Author

RMeli commented Oct 14, 2024

@IAlibay I rebased on develop and this time it seemed to work alright. It should be good to go if CI comes back green. Thanks for the help!

.git-blame-ignore-revs Outdated Show resolved Hide resolved
RMeli added 2 commits October 14, 2024 21:21
black config

ignore formatting git blame
@RMeli
Copy link
Member Author

RMeli commented Oct 14, 2024

The ignored commit was wrong, I fixed that and squashed down to two commits.

@RMeli
Copy link
Member Author

RMeli commented Oct 14, 2024

This workflow is not great IMO, it requires a lot of git-foo. I suggest that going forward I take note of the different black PRs that are squash-merged (maybe in an issue), and then periodically open a PR to add them to .git-blame-ignore-revs.

@orbeckst
Copy link
Member

If we agree to use a common title for black-only commits or add a magic comment then we could (semi)automate adding to the exclusion file.

@RMeli
Copy link
Member Author

RMeli commented Oct 15, 2024

Excellent suggestion @orbeckst. I suggest we use [fmt] as tag for formatting-related PRs.

@RMeli RMeli merged commit 48e9e01 into MDAnalysis:develop Oct 15, 2024
23 of 24 checks passed
@RMeli RMeli deleted the black-ci branch October 15, 2024 19:54
@RMeli RMeli changed the title Add CI step for black (and remove darker) [fmt] Add CI step for black (and remove darker) Dec 29, 2024
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.

4 participants