Skip to content

Introduce black & fix flake8 #743

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

Merged
merged 1 commit into from
Oct 4, 2023
Merged

Introduce black & fix flake8 #743

merged 1 commit into from
Oct 4, 2023

Conversation

kellerza
Copy link
Contributor

@kellerza kellerza commented Oct 3, 2023

Would you be interested to introduce black for code formatting?

Black fixes the majority of the flake8 issue present in the library today: blanks lines at the end of files, too many blank lines, visual indents, etc

Although Black requires Python 3 to run, it can safely format code for Python 2 and execute as a pre-commit hook.

To implement the Black fixes, you can execute the following:

pip install pre-commit
pre-commit install
pre-commit run --all

You can see an example of changes here - but this will be a PITA to review, so it's probably best that you do the initial Black run and commit it before we continue

@kellerza
Copy link
Contributor Author

kellerza commented Oct 3, 2023

This also adds isort to sort & group import statements

@vgrem
Copy link
Owner

vgrem commented Oct 4, 2023

Greetings,

thank you for the suggestion! Perhaps IDE could do the job in terms of runing pre-commit within the IDE instead of triggering it manually, for instance PyCharm supports Black formatter integration Lets give it a try.

@vgrem vgrem closed this Oct 4, 2023
@vgrem vgrem reopened this Oct 4, 2023
@vgrem vgrem merged commit 6d3e645 into vgrem:master Oct 4, 2023
@kellerza
Copy link
Contributor Author

kellerza commented Oct 4, 2023

It should be consistent if you do it via the IDE (pycharm/vscode) and pre-commit (black has almost no settings)

The nice thing about pre-commit is that its a hook on "git commit" that just ensures this irrespective of your IDE.

@kellerza kellerza deleted the black2 branch October 4, 2023 14:42
vgrem added a commit that referenced this pull request Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants