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 configuration and instructions #4878

Closed
wants to merge 1 commit into from

Conversation

stefanv
Copy link
Member

@stefanv stefanv commented Jul 31, 2020

I recommend we switch to pre-commit and disable pep8speaks. Turns out, if you don't enforce it it gets ignored :) I think this is actually a friendlier experience for contributors, since they get to sort out all the annoying PEP8 nitpicks before review.

Note, the test suite will now definitely fail, but I didn't want to pollute this PR with thousands of PEP8 tweaks.

We can also adjust the PEP8 rules we want to enforce, although I already disabled the ones I think we don't care about.

@hmaarrfk
Copy link
Member

hmaarrfk commented Aug 1, 2020

I would really prefer if we tabled the instruction update to avoid a conflict.

Running pep8 on all builds is also annoying since linting disrupts general tests.
A dedicated build for linting would be appreciated.

@stefanv
Copy link
Member Author

stefanv commented Aug 2, 2020

The whole point of the pre-commit hook is that this test should never fail. When it does, rather fail early? A special entry just for linting feels like overkill (but, if that's general consensus, ok).

Why would the instruction update generate a conflict? And, if it does, would it be hard to fix?

Comment on lines +13 to +16
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.782'
hooks:
- id: mypy
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this mypy stuff needed or is it just here for future use? We didn't actually commit any typed code yet did we?

@grlee77
Copy link
Contributor

grlee77 commented Aug 2, 2020

I have used a flake8 pre-commit on some other projects and have liked it so far.

@emmanuelle
Copy link
Member

My two cents: the pep8-quality of our code is reasonable, and so is the quality of code submitted by contributors (and I think pep8speaks is useful, most people). I err on the side of less infrastructure imposed on contributors. pep8 is here so that code is nice and fast to read because of consistency with other projects, I think our code is nice enough to read.

@stefanv
Copy link
Member Author

stefanv commented Aug 6, 2020

@emmanuelle I don't quite understand: this PR only enforces pep8, and makes it easier for developers to catch those errors early? I don't think it imposes more than pep8speaks. It just makes sure people notice it, since pep8speaks clearly often is ignored (witness how many our files are not pep8 compliant).

@emmanuelle
Copy link
Member

@stefanv sorry if I was not clear. What I meant basically is that it's one more step (pip installing pre-commit) to do before one can submit a PR.

@hmaarrfk
Copy link
Member

hmaarrfk commented Aug 7, 2020

I err on the side of less infrastructure imposed on contributors.

I agree with Emanuelle's sentiment.

@grlee77
Copy link
Contributor

grlee77 commented Aug 7, 2020

I find the pre-commit approach more convenient than finding out after creating the PR that I forgot to fix PEP-8 issues. pep8speaks does work fine, though, so I don't have a real problem sticking with that approach either.

It is one additional thing to set up as a first-time contributor, but it seems fairly easy relative to learning to use git itself.

@jni
Copy link
Member

jni commented Feb 12, 2021

The whole point of the pre-commit hook is that this test should never fail. When it does, rather fail early? A special entry just for linting feels like overkill (but, if that's general consensus, ok).

An important point is that if a contributor has not installed the pre-commit hook (this has happened even to me on the napari repo when I was working on a new machine, for example), it's useful information for maintainers to know whether the actual code is working even if the linter fails. So, for napari we have separate checks for both linting and formatting and that's been working well.

@jni
Copy link
Member

jni commented Feb 12, 2021

pep8speaks clearly often is ignored (witness how many our files are not pep8 compliant).

But very often it should be ignored, e.g. in array literal formatting... All of these auto-formatters ignore the opening clause of PEP8.

@stefanv
Copy link
Member Author

stefanv commented Feb 12, 2021

It becomes very easy to run this as part of the CI by simply invoking pre-commit the same way the user would.

Base automatically changed from master to main February 18, 2021 18:23
@stefanv stefanv closed this Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚖️ Needs decision 🤖 type: Infrastructure CI, packaging, tools and automation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants