-
Notifications
You must be signed in to change notification settings - Fork 41
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 code style #640
Use black code style #640
Conversation
Flake8 linting was done also in the pytest step
Codecov ReportBase: 99.58% // Head: 99.58% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #640 +/- ##
=======================================
Coverage 99.58% 99.58%
=======================================
Files 87 87
Lines 5990 5991 +1
=======================================
+ Hits 5965 5966 +1
Misses 25 25
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
BTW, there exists also the isort tool to sort import statements, which would be one automation step more. |
CodeClimate complains about too long lines. The complaints by other code-style tools seem unimportant. The SonarCloud complaints about http protocol could could be just marked safe. |
@osma How does this look? One question is whether to switch using max. line length of 88 chars. |
I think it looks very good already. Re: line length, I think 88 is OK, but is there a way to tell that to Code Climate so it won't complain? |
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.
Very good!
a6f007b
to
f5bc54d
Compare
SonarCloud Quality Gate failed. 0 Bugs No Coverage information |
Force pushed after fixing completely typoed commit message. The commit to |
Integrates Black code style tool to development flow and formats codebase to follow Black default style.
The main changes that Black makes when using the default style seem to be:
[i : i + j]
It would be possible to skip some of the changes with custom configuration (like in branch issue609-use-black-code-style-less-changes, where quotes are not changed and the 79 max. line length is retained). However, I think it could be better just to use the default Black style.
The
.git-blame-ignore-revs
file hides (some) of the changed lines in git-blame view of the style migration commit.Manual local usage
The Black tool is added to the development dependencies, and the codebase can be formatted with one command. If nothing is left to be changed, the run is:
When using Black the
autopep8.sh
script is unnecessary and it is removed.Automated local usage
The pre-commit hook for linting with black and flake8 can be configured by using the following in the file
.git/hooks/pre-commit
:There exists the precommit-framework, which could automate the installation of the hook, but the hook would need to be defined in
.pre-commit-config.yaml
file. I don't know if using the precommit-framework is worth adding yet another dev dependency. This blog showed how that could be used.(There exists also the pytest-black plugin, but it seems unmaintained.)
CI usage
Adds a new "lint with Black" job to GitHub Actions CI workflow, which uses the Action provided by Black developers to just check the format (uses options
--check --diff
). It is run in parallel with unit test jobs.I noticed that the separate Flake8 step for linting has been redundant, because flake8 linting is run also with the pytest, so the separate Flake8 step is removed.
IDE integration
In VS Code the Black was already included and could be selected as the formatter.
Closes #609.