Conversation
There was a problem hiding this comment.
These also come to mind:
- Yes, also flake8 (hadn't seen autoflake8 before, i'm assuming its a variation)
General linters/formatters:
- pylint
- mypy - related, but not just about formatting, and should be a separate effort than this to add type hints everywhere
|
Wow, this seems to be moving fast. Maybe the deadline is a little bit tight given that we haven't fully figured out what we want and haven't even tested it? Here are some of my considerations:
|
A few of these seem to be covered already e.g. by black
Seems like this can be addressed in a follow up PR.
Are there specific checks in this list that have performance concerns? "if you remember to do it" is the issue -- keep in mind the time spent if you miss a check, and find out later in a github action. It's much less hostile to just enforce with a pre-commit hook. This seems like an established best practice, and not really an issue in practice given the speed of most of these invoked from pre-commit.
|
Indeed, i'm sometimes a bit impatient 🙈 Also, the target was more to merge the others PR so we are clear to make big changes, not to merge the black PR today.
It could still be nice to enable check-case-conflict, end-of-file-fixer, mixed-line-ending, trailing-whitespace to fix the non-python files imo.
To me, mypy is a bit too slow to be enabled in the pre-commit , i think. (But i don't have a very strong opinion on this.)
I'm also for longer line lengths in general, the time where we had very small screens is long behind us. (But again, not a strong opinion)
Here it is: main...formatting-results |
|
Nice, thanks for running all these things! Do you recall how long the individual steps / the overall process took? The results look pretty good to me, especially because it seems that the limit is not strictly enforced for strings, where breaking up would really hinder readability. The only weird thing is how format strings are sometimes replaced by the "{}".format() notations, sometimes converted to f-strings and sometimes left as-is. As f-string were introduced in 3.6, they would be the way to go everywhere - do we have a way about warning when the other formats are used? |
|
After the first run (that installs the tools, etc), a full run takes 2.57s on my machine. But we also have to keep in mind that a full run is almost never done as by default, pre-commit runs only on modified files so it's much much faster.
This is weird, i'll have a look at the options of pyupgrade to try and force f-strings everywhere. |
|
The doc of pyupgrade says :
And i see no option to override this behaviour. I had a look around the internet and it seems that there is another tool to do this: flynt. Note: what we could also do, is to run it once right now to get rid of the legacy and then rely on pyupgrade afterwards, this might be good enough. |
I've done that in several projects (e.g., https://github.com/networkx/networkx) and it worked well. |
|
It took a few commits to pass cleanly the tests but i'm happy to say that it's now merged and that we have a GitHub action enforcing the pre-commits ! |
See #344
Adds pre-commit, black, isort, pyupgrade, blacken-docs.
Missing:
This PR will make a lot of noise: changing almost every file, sneaking into git blame, introducing conflicts in open PR, ...
So i would like to:
Should we add some more auto-formatters ? Something like https://github.com/fsouza/autoflake8 maybe ? Do you have some other ideas ? Now is the time !