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

Add .pre-commit-config.yaml for local setup #895

Merged
merged 7 commits into from
May 18, 2022

Conversation

lebrice
Copy link
Collaborator

@lebrice lebrice commented Apr 22, 2022

Devs can optionally turn on pre-commit locally using:

$ pip install pre-commit
$ pre-commit install

Then, the following actions are performed on the diff before it is committed locally:

  • black: Reformat the code using black
  • codespell: Check for spelling mistakes
  • flake8: check for various code quality issues
  • isort: sort imports
  • pyupgrade: Remove outdated python syntax stuff from the code (e.g. super(thing, self), etc)
  • autoflake: Remove unused imports

If any of the above hooks fail, the commit is interrupted, the differences get added as modifications, and the user can add them before the commit goes through.

It's really simple and convenient.

The only thing that I'm not 100% sure about is codespell, which I think might generate a bunch of false positives. Even then, it's always possible to just add words to the ignored words list, as needed.

Signed-off-by: Fabrice Normandin <normandf@mila.quebec>
Signed-off-by: Fabrice Normandin <normandf@mila.quebec>
Signed-off-by: Fabrice Normandin <normandf@mila.quebec>
Signed-off-by: Fabrice Normandin <normandf@mila.quebec>
Signed-off-by: Fabrice Normandin <normandf@mila.quebec>
@lebrice
Copy link
Collaborator Author

lebrice commented May 3, 2022

Fixes #892

Signed-off-by: Fabrice Normandin <normandf@mila.quebec>
Signed-off-by: Fabrice Normandin <normandf@mila.quebec>
.pre-commit-config.yaml Show resolved Hide resolved
@bouthilx
Copy link
Member

It would be great to reuse this for the tests instead of duplicating them. It would help avoid mismatches when we update black version or some configuration in tox. May be worth creating an issue.

@lebrice lebrice merged commit e488700 into Epistimio:develop May 18, 2022
@bouthilx bouthilx added the ci label May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants