Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Enforce a code style #208

Closed
ardunn opened this issue May 4, 2019 · 3 comments · Fixed by #245
Closed

Enforce a code style #208

ardunn opened this issue May 4, 2019 · 3 comments · Fixed by #245

Comments

@ardunn
Copy link
Contributor

ardunn commented May 4, 2019

e.g., black formatting.

https://github.com/python/black

@ardunn ardunn added the easy label Oct 4, 2019
@janosh
Copy link
Member

janosh commented Oct 8, 2019

I can recommend black in conjunction with flake8 which would do the style enforcing. For instance, this is the config I use (specified in setup.cfg):

[flake8]
max-line-length = 100
exclude = .git
# E731: do not assign a lambda expression, use a def
# W293: blank line contains whitespace
# E203: whitespace before ':'
# E265: block comment should start with '# '
# W503: line break before binary operator
ignore = E203, E731, W293, E265, W503

# make isort play nicely with black's import formatting
# https://github.com/microsoft/vscode-python/issues/5840
[isort]
multi_line_output = 3
include_trailing_comma = True

@utf
Copy link
Member

utf commented Oct 11, 2019

I think using black is a great idea. I'm not sure about some of those exceptions though. Particularly, it seems useful to have checks for these:

# W293: blank line contains whitespace
# E203: whitespace before ':'
# E265: block comment should start with '# '
# W503: line break before binary operator

@janosh
Copy link
Member

janosh commented Oct 11, 2019

@utf Sure, I just copied those over from another project where they accumulated over time to act as an example.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants