Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

Add bot to reformat code #1319

Closed
astrojuanlu opened this issue Sep 13, 2021 · 3 comments · Fixed by #1331
Closed

Add bot to reformat code #1319

astrojuanlu opened this issue Sep 13, 2021 · 3 comments · Fixed by #1331

Comments

@astrojuanlu
Copy link
Member

When first-time contributors open a pull request, usually they are not aware that they have to run tox -e reformat before committing. Although we have documented these steps in our CONTRIBUTING.md (but not on our Contribute page!), it is normal that some people don't read it.

What usually happens next is that we have to either merge code with a failing quality check (we almost never do that) or ask the user to amend some silly whitespace issues (which is annoying and not always fool-proof).

Instead of fighting against this, I propose we have a bot that we can ask

@bot, please reformat code

and then it pushes another commit to the same branch.

Similar examples:

@astrojuanlu
Copy link
Member Author

What sorcery is this 😱 pradyunsg/furo@37bfcc4 Looks like https://pre-commit.ci/ is what we need?

@matthewfeickert
Copy link
Contributor

Looks like https://pre-commit.ci/ is what we need?

I was going to say, pre-commit.ci is the way to go! :) We use it extensively in Scikit-HEP (c.f. developer recommendations) and the fact that it just takes care of things and pushes back is super nice.

Would you be open to a PR that simply implements

poliastro/tox.ini

Lines 64 to 72 in 2e38094

[testenv:reformat]
description = reformats the code using black and isort
deps =
black==21.5b0
isort
skip_install = true
commands =
isort --project poliastro --section-default THIRDPARTY src tests
black src tests

in .pre-commit-config.yaml (this also requires poliastro to register for pre-commit.ci)?

@astrojuanlu
Copy link
Member Author

Absolutely @matthewfeickert ! 🙌🏼

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants