-
Notifications
You must be signed in to change notification settings - Fork 378
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
Use black to format code #579
Conversation
Python 3.5 seems to be a culprit again, as it cannot parse trailing commas after **kwargs, which are currently inserted by black even though they should not be. I therefore formatted the affected files and turned the formatting off afterwards (only three files where affected). I would leave it this way until the bug is fixed in black (or I find out what I am doing wrong). |
rev: stable | ||
hooks: | ||
- id: black | ||
language_version: python3.6 |
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.
What if you put python3.5 here? Would that fix the issues?
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.
Just fixed the issue by using the black from the master branch in the pre-commit hook. language_version:
here just refers to the python version of the virtual env in which the precommit hook is run. The python version that black supports is configured in pyproject.toml
Small question: Is there a reason not to use For example in sacred are more lines that contain
|
@boeddeker I agree with that. Our goal when using black was mainly to avoid pushing commits to fix pep8. If we use single quotes or double quotes doesn't matter for pep8 and doesn't change the structure of the code. Also, the diff of the current PR will be much smaller if we do that. |
@boeddeker I would say the whole purpose of black is to have consistent formatting for the whole python community. I also used to use single quotes and at the beginning the felt very strange to now have double quotes all over my code. However, I quickly got used to it and I believe that consistency in the community is more valuable than personal preference.
As we do not have any of those conventions, I see no benefit in sticking with the current quoting. If you still like to write your code using single quotes you can do so and the precommit hook will take care of formatting your code. |
I actually don't have any strong feeling from either sides after thinking about it. As long as I don't have to push commits for pep8, I'll be happy. |
So from my side this would be ready now. |
we should really drop appveyor, it takes forever to run. |
@@ -28,4 +28,4 @@ wrapt==1.10.8 | |||
scikit-learn==0.20.3 | |||
pymongo==3.8.0 | |||
py-cpuinfo==4.0 | |||
|
|||
pre-commit==1.18.0 |
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.
should we add black here? when does it get downloaded?
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.
I first had it there, but then the py35 build fails, because it installs the dev-requirements
but black needs py36 to run.
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.
so black
will get downloaded when you commit the first time after running pre-commit install
. It is installed in its own virtual environment that does not contain anything else.
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.
I see, that makes sense. I'll merge it then.
@JarnoRFB Thanks for the explanation. |
Closes #576