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

Easy way to run lint, black etc. (all fast checks) #15076

Closed
JukkaL opened this issue Apr 18, 2023 · 4 comments · Fixed by #15210
Closed

Easy way to run lint, black etc. (all fast checks) #15076

JukkaL opened this issue Apr 18, 2023 · 4 comments · Fixed by #15210
Labels
feature good-first-issue topic-developer Issues relevant to mypy developers

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Apr 18, 2023

Add an easy way to run runtests.py self lint format-black format-isort. Often one of these fails in CI, so running them locally is helpful, but currently it's too annoying. It could be runtests.py <something>.

@JukkaL JukkaL added feature topic-developer Issues relevant to mypy developers good-first-issue labels Apr 18, 2023
@JelleZijlstra
Copy link
Member

I think this is pretty easy to do with pre-commit, something like pre-commit run -a black. Perhaps we could provide an alias for a pre-commit invocation like that. (Note that this does not require actually using pre-commit as a pre-commit hook.)

@hauntsaninja
Copy link
Collaborator

@JukkaL The best flow for contributors is where they don't need to think about black and isort at all. If you setup #13281 it'll just automatically push fixup commits; we use this in typeshed and it works great. Contributors don't have to think about pre-commit or any other tool

@AlexWaygood
Copy link
Member

I agree with @hauntsaninja! pre-commit.ci has worked seamlessly at typeshed and really improved the contributing experience. It's very easy to enable it for a repo; just a matter of ticking a box in the repo settings to give it the necessary permissions.

@JukkaL
Copy link
Collaborator Author

JukkaL commented Apr 19, 2023

Yes, running black and isort automatically for PRs sounds like a good idea. That would address much of the friction.

I think that this issue is still worthwhile, particularly for self check and lint, which often require manual action, but running black and isort is also pretty quick and by running them locally there won't be need to pull fixup commits .

JelleZijlstra pushed a commit that referenced this issue May 13, 2023
This makes it easier to maintain the configurations for the various
linting tools we use in CI. It also makes it easier for contributors to
run the linting tools locally. `black`, `isort` and `flake8` are all
very fast checks, so I think it makes sense to just run them all
together in `runtests.py`.

With this PR, the following three invocations will all be equivalent:

```
pre-commit run --all-files
python runtests.py lint
tox -e lint
```

Closes #15076
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature good-first-issue topic-developer Issues relevant to mypy developers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants