-
Notifications
You must be signed in to change notification settings - Fork 130
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 reformat code #778
Conversation
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.
@vondele incredible coincidence, I created locally the same branch yesterday :)
"assert" is a statement and not a function, in master was written with parenthesis in a dangerous way, black fixes this dubious coding style.
https://stackoverflow.com/questions/13390401/design-of-python-why-is-assert-a-statement-and-not-a-function
https://stackoverflow.com/questions/3112171/python-assert-with-and-without-parenthesis
@vondele what about sorting the imports using |
(VERSION 4.3.4) Edit: fixed with |
Tested OK on DEV/workers. |
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.
Looks good to me
@vondele please format and sort the new master. |
black --exclude=worker/requests . isort --profile black --skip worker/requests . no functional change
@ppigazzini updated to the latest master. |
Fast check OK on DEV and workers, PROD updated, thank you @vondele :) |
I added this GitHub action on my repo to check format and import order on PR: After some tests we could add the action of the official repo. BTW it seems that different black versions work in different ways, the action failed on master and I was able to reformat some files:
|
Here: |
It's a problem only if adding a github action to check the format. BTW it seems not possible to auto format a PR opened from a fork, see: |
well if not all devs use the same version of black, probably PRs will be a bit cluttered. |
These should be the actual smart ways to setup a python dev env: |
btw, I just checked that the older version of black I use doesn't change back the changes made by the newer black. All changes where in the documentation strings of functions. Presumably that was like a new feature introduced. |
@vondele @tomtor @vdbergh IMO this is interesting https://jacobian.org/2019/nov/11/python-environment-2020/ pyenvI updated my dev env, DEV and my test workers to python3.8.5 to test the stability, here is a benchmark for the python releases (PROD uses 3.6.9) Notes:
pipxUseful to have black, isort, awscli and other cli python tools in only one standard venv poetryNot really used yet :) |
@vondele @tomtor @vdbergh python 3.8.6 is saving a lot of memory on PROD.
|
this reformats the code using
black --exclude=worker/requests .
fixes #634
as with any tool, not all is perfect, but things are pretty consistent.
I propose to apply this patch (or execute the above black command) as part of the next worker change.