-
-
Notifications
You must be signed in to change notification settings - Fork 417
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
style: pre-commit basic config #1151
style: pre-commit basic config #1151
Conversation
Why did it modify the SVGs?
It sounds like a good fit for pre-commit. But moved from where? pyupgrade looks nice! (with Is there a way to split the pre-commit, so that checks run automatically (like with install), but modifications need to be run manually?
|
start: "a" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be excluded! :)
Probably for consistent end lines or extra whitespace.
Currently it's sitting in tox.ini.
What doesn't support f-strings? Pyupgrade will convert
There's not that much you can do beyond whitespace and a few minor things in Python. We don't have an equivalent to Rubocop for Python. Most tools are just linters only.
Pre-commit is just the name of the tool. It's not a very good name.
You can set stages on all hooks. There is a manual hook stage, but you have to specify it when running pre-commit. I'm not sure if you can specify a "non-precommit" state that runs manually without adding It's worth trying out, though, if you haven't. It's very well done - it handles partial checkings, for example, by copying to a temp directory and running there, etc. I'd recommend trying out everything on the page I shared, one at a time, eventually. I'll only be adding this (I was having issues with line endings on my last PR), pyupgrade, and maybe some linting checks - I'm really after improving the typing coverage a bit so I can measure the impact of mypyc. MyPy and Black both use mypypc to get nice speedups. Style formatting (Black, isort, etc) are a personal choice, and not a usually a good contribution unless asked for.
You can still activate pre-commit.ci, but leave changes off. We do that in pypa/build. You still get the fast checks & weekly updates. I'll add a couple of exclusions, and repush, and we can go from there. Probably in an hour or two. Footnotes
|
Probably best to exclude SVGs.
Doesn't it make sense to have it in both?
That would be great. When I tried, it converted them to
Good call. I'm not a fan of reformatters, and have bad experience with isort.
Sounds good. I'm also curious to know if the type info produces any speed-up, and by how much. |
I'll also exclude
Sure, but it should be defined once (in pre-commit), and simply run from there via tox.
Ah, you forgot to pass
Probably some time ago? It was reworked and it very good these days. And Black is great - once you get used to reading blacked code, it becomes really easy to read lots of code bases. |
341d7b3
to
ce7dd7b
Compare
Here's the report so you can see all changed files and why they were changed:
|
Also, if you rebase-and-merge or classic merge, then you can add the second commit's sha to your .git-ignore-revs file and GitHub will ignore that commit in history (blame) view (recent addition to GitHub). |
Only thing I noticed was that the comment in |
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
ce7dd7b
to
5236ff9
Compare
Thanks you for your contribution! Sorry that it took so long to review. My mind's been on other projects. |
No problem, my mind has been too. I'll pop back here once and a while and try to slowly work on more typing, still curios to try mypyc. |
This adds a basic pre-commit-config, a tox job running it (to help new contributors - usually you should run pre-commit directly to take advantage of it's start-up speed), and a GitHub job. Pre-commit is from Anthony Sottile, the developer behind flake8, pytest, tox, and other tools. You can read more about it at https://pre-commit.com or https://scikit-hep.org/developer/style. You can see it on many of the PyPA repos, like build, pip, pipx, cibuildwheel, etc. If you want, there's also a pre-commit.ci service that will auto-update your pre-commit file and auto-fix PRs, and is ultra-fast.
If you like this, I can add a few more checks, starting with the basics. MyPy can be moved to pre-commit as well. I won't add black or isort unless you ask for them, but I think you'll really like pyupgrade.
By the way, you can exclude files, even per-check, so let me know if there's any that intentionally unusual (like wrong file endings) for testing purposes. I can also ignore SVGs, etc, quite easily.
FYI, I mostly run
pre-commit run -a
like you might run nox or tox, but you can also runpre-commit install
and have it run in "precommit hook mode", where it checks on commit unless you pass-n
.