Skip to content
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

Format with Black #427

Closed
wants to merge 2 commits into from
Closed

Format with Black #427

wants to merge 2 commits into from

Conversation

hugovk
Copy link
Member

@hugovk hugovk commented Nov 10, 2019

For #401

Locally:

# Install
pip install -U black

# Run
black .

Also run as part of:

pre-commit run --all-files

# Or
pre-commit run --all-files black

# Or
tox -e lint

Also run as part of the CI lint jobs.

@claudep
Copy link
Contributor

claudep commented Nov 10, 2019

You cannot imagine how I hate this black stuff, mostly polluting the git history for almost no gain :-( Sorry to be so negative about this.

@hugovk hugovk mentioned this pull request Nov 10, 2019
@claudep
Copy link
Contributor

claudep commented Nov 11, 2019

Would you find it acceptable to work on flake8 integration and not using black (until my stubborn spirit get convinced)?

@hugovk
Copy link
Member Author

hugovk commented Nov 11, 2019

Not really, I'd rather not manually fix dozens of styling/formatting changes if they can be (mostly) done automatically:

$ flake8 --statistics --count
./setup.py:10:57: W504 line break after binary operator
./tests/test_tablib.py:171:9: E731 do not assign a lambda expression, use a def
./tests/test_tablib_dbfpy_packages_utils.py:154:13: F841 local variable 'output' is assigned to but never used
./docs/conf.py:34:1: E265 block comment should start with '# '
./docs/conf.py:55:1: E265 block comment should start with '# '
./docs/conf.py:59:1: E265 block comment should start with '# '
./docs/conf.py:61:1: E265 block comment should start with '# '
./docs/conf.py:68:1: E265 block comment should start with '# '
./docs/conf.py:79:1: E265 block comment should start with '# '
./docs/conf.py:85:1: E265 block comment should start with '# '
./docs/conf.py:97:1: E265 block comment should start with '# '
./docs/conf.py:100:1: E265 block comment should start with '# '
./docs/conf.py:104:1: E265 block comment should start with '# '
./docs/conf.py:107:1: E265 block comment should start with '# '
./docs/conf.py:111:1: E265 block comment should start with '# '
./docs/conf.py:116:1: E265 block comment should start with '# '
./docs/conf.py:125:1: E265 block comment should start with '# '
./docs/conf.py:133:13: E241 multiple spaces after ':'
./docs/conf.py:134:10: E241 multiple spaces after ':'
./docs/conf.py:140:1: E265 block comment should start with '# '
./docs/conf.py:143:1: E265 block comment should start with '# '
./docs/conf.py:146:1: E265 block comment should start with '# '
./docs/conf.py:149:1: E265 block comment should start with '# '
./docs/conf.py:158:1: E265 block comment should start with '# '
./docs/conf.py:163:1: E265 block comment should start with '# '
./docs/conf.py:166:1: E265 block comment should start with '# '
./docs/conf.py:175:1: E265 block comment should start with '# '
./docs/conf.py:178:1: E265 block comment should start with '# '
./docs/conf.py:183:3: E121 continuation line under-indented for hanging indent
./docs/conf.py:190:17: E241 multiple spaces after ':'
./docs/conf.py:191:17: E241 multiple spaces after ':'
./docs/conf.py:197:1: E265 block comment should start with '# '
./docs/conf.py:201:1: E265 block comment should start with '# '
./docs/conf.py:204:1: E265 block comment should start with '# '
./docs/conf.py:207:1: E265 block comment should start with '# '
./docs/conf.py:210:1: E265 block comment should start with '# '
./docs/conf.py:213:1: E265 block comment should start with '# '
./docs/conf.py:216:1: E265 block comment should start with '# '
./src/tablib/__init__.py:3:1: F401 'tablib.core.Databook' imported but unused
./src/tablib/__init__.py:3:1: F401 'tablib.core.Dataset' imported but unused
./src/tablib/__init__.py:3:1: F401 'tablib.core.InvalidDatasetType' imported but unused
./src/tablib/__init__.py:3:1: F401 'tablib.core.InvalidDimensions' imported but unused
./src/tablib/__init__.py:3:1: F401 'tablib.core.UnsupportedFormat' imported but unused
./src/tablib/__init__.py:3:1: F401 'tablib.core.detect_format' imported but unused
./src/tablib/__init__.py:3:1: F401 'tablib.core.import_book' imported but unused
./src/tablib/__init__.py:3:1: F401 'tablib.core.import_set' imported but unused
./src/tablib/core.py:15:1: F401 'tablib.formats' imported but unused
./src/tablib/core.py:415:1: W293 blank line contains whitespace
./src/tablib/formats/_rst.py:66:13: E731 do not assign a lambda expression, use a def
./src/tablib/formats/_rst.py:68:13: E731 do not assign a lambda expression, use a def
./src/tablib/formats/_rst.py:70:13: E731 do not assign a lambda expression, use a def
./src/tablib/formats/_rst.py:89:5: E303 too many blank lines (2)
./src/tablib/formats/_rst.py:116:29: F821 undefined name '_get_column_widths'
./src/tablib/formats/_rst.py:188:5: E303 too many blank lines (2)
./src/tablib/formats/_ods.py:63:21: E266 too many leading '#' for block comment
./src/tablib/formats/_xls.py:67:5: E303 too many blank lines (2)
./src/tablib/formats/__init__.py:57:65: W291 trailing whitespace
./src/tablib/formats/_dbf.py:62:9: E265 block comment should start with '# '
./src/tablib/formats/_dbf.py:66:13: F841 local variable '_dbf' is assigned to but never used
./src/tablib/packages/dbfpy/dbfnew.py:27:1: E402 module level import not at top of file
./src/tablib/packages/dbfpy/dbfnew.py:27:1: F403 'from .dbf import *' used; unable to detect undefined names
./src/tablib/packages/dbfpy/dbfnew.py:28:1: E402 module level import not at top of file
./src/tablib/packages/dbfpy/dbfnew.py:28:1: F403 'from .fields import *' used; unable to detect undefined names
./src/tablib/packages/dbfpy/dbfnew.py:29:1: E402 module level import not at top of file
./src/tablib/packages/dbfpy/dbfnew.py:29:1: F403 'from .header import *' used; unable to detect undefined names
./src/tablib/packages/dbfpy/dbfnew.py:30:1: E402 module level import not at top of file
./src/tablib/packages/dbfpy/dbfnew.py:30:1: F403 'from .record import *' used; unable to detect undefined names
./src/tablib/packages/dbfpy/dbfnew.py:50:9: F405 'cls' may be undefined, or defined from star imports: .dbf, .fields, .header, .record
./src/tablib/packages/dbfpy/dbfnew.py:51:15: F405 'DbfCharacterFieldDef' may be undefined, or defined from star imports: .dbf, .fields, .header, .record
./src/tablib/packages/dbfpy/dbfnew.py:52:15: F405 'DbfNumericFieldDef' may be undefined, or defined from star imports: .dbf, .fields, .header, .record
./src/tablib/packages/dbfpy/dbfnew.py:53:15: F405 'DbfLogicalFieldDef' may be undefined, or defined from star imports: .dbf, .fields, .header, .record
./src/tablib/packages/dbfpy/dbfnew.py:56:15: F405 'DbfDateFieldDef' may be undefined, or defined from star imports: .dbf, .fields, .header, .record
./src/tablib/packages/dbfpy/dbfnew.py:60:15: F405 'DbfDateTimeFieldDef' may be undefined, or defined from star imports: .dbf, .fields, .header, .record
./src/tablib/packages/dbfpy/dbfnew.py:139:17: F405 'DbfHeader' may be undefined, or defined from star imports: .dbf, .fields, .header, .record
./src/tablib/packages/dbfpy/dbfnew.py:158:12: F405 'Dbf' may be undefined, or defined from star imports: .dbf, .fields, .header, .record
./src/tablib/packages/dbfpy/dbfnew.py:161:11: F405 'DbfRecord' may be undefined, or defined from star imports: .dbf, .fields, .header, .record
./src/tablib/packages/dbfpy/dbfnew.py:167:11: F405 'DbfRecord' may be undefined, or defined from star imports: .dbf, .fields, .header, .record
./src/tablib/packages/dbfpy/fields.py:33:1: E402 module level import not at top of file
./src/tablib/packages/dbfpy/fields.py:34:1: E402 module level import not at top of file
./src/tablib/packages/dbfpy/fields.py:35:1: E402 module level import not at top of file
./src/tablib/packages/dbfpy/fields.py:35:1: F401 'sys' imported but unused
./src/tablib/packages/dbfpy/fields.py:36:1: E402 module level import not at top of file
./src/tablib/packages/dbfpy/fields.py:38:1: E402 module level import not at top of file
./src/tablib/packages/dbfpy/fields.py:147:19: W504 line break after binary operator
./src/tablib/packages/dbfpy/fields.py:148:27: W504 line break after binary operator
./src/tablib/packages/dbfpy/fields.py:150:24: W504 line break after binary operator
./src/tablib/packages/dbfpy/fields.py:151:30: W504 line break after binary operator
./src/tablib/packages/dbfpy/fields.py:152:36: W504 line break after binary operator
./src/tablib/packages/dbfpy/header.py:22:1: E402 module level import not at top of file
./src/tablib/packages/dbfpy/header.py:23:1: E402 module level import not at top of file
./src/tablib/packages/dbfpy/header.py:24:1: E402 module level import not at top of file
./src/tablib/packages/dbfpy/header.py:25:1: E402 module level import not at top of file
./src/tablib/packages/dbfpy/header.py:27:1: E402 module level import not at top of file
./src/tablib/packages/dbfpy/header.py:28:1: E402 module level import not at top of file
./src/tablib/packages/dbfpy/dbf.py:65:1: E402 module level import not at top of file
./src/tablib/packages/dbfpy/dbf.py:66:1: E402 module level import not at top of file
./src/tablib/packages/dbfpy/utils.py:16:1: E402 module level import not at top of file
./src/tablib/packages/dbfpy/utils.py:17:1: E402 module level import not at top of file
./src/tablib/packages/dbfpy/record.py:19:1: E402 module level import not at top of file
./src/tablib/packages/dbfpy/record.py:21:1: E402 module level import not at top of file
./src/tablib/packages/dbfpy/record.py:85:69: E502 the backslash is redundant between brackets
./src/tablib/packages/dbfpy/record.py:104:49: W504 line break after binary operator
./src/tablib/packages/dbfpy/record.py:140:41: E225 missing whitespace around operator
./src/tablib/packages/dbfpy/record.py:227:12: E121 continuation line under-indented for hanging indent
./src/tablib/packages/dbfpy/record.py:228:13: E131 continuation line unaligned for hanging indent
2     E121 continuation line under-indented for hanging indent
1     E131 continuation line unaligned for hanging indent
1     E225 missing whitespace around operator
4     E241 multiple spaces after ':'
31    E265 block comment should start with '# '
1     E266 too many leading '#' for block comment
3     E303 too many blank lines (2)
21    E402 module level import not at top of file
1     E502 the backslash is redundant between brackets
4     E731 do not assign a lambda expression, use a def
10    F401 'tablib.core.Databook' imported but unused
4     F403 'from .dbf import *' used; unable to detect undefined names
10    F405 'cls' may be undefined, or defined from star imports: .dbf, .fields, .header, .record
1     F821 undefined name '_get_column_widths'
2     F841 local variable '_dbf' is assigned to but never used
1     W291 trailing whitespace
1     W293 blank line contains whitespace
7     W504 line break after binary operator
105

@hugovk
Copy link
Member Author

hugovk commented Nov 11, 2019

But we can definitely skip Black if you're not keen on it.

It's not for everyone, and it's in no-one's interest if it in any way discourages you from maintaining Tablib.

@claudep
Copy link
Contributor

claudep commented Nov 11, 2019

Note that I'm happy to do the work of fixing flake8 errors myself. I just want to discuss some settings, like not limiting lines to 88 chars (Django uses 119 with satisfaction, but I'm fine with any number around 100).

@hugovk
Copy link
Member Author

hugovk commented Nov 11, 2019

I'd rather not have it too big. Although modern screens/editors can easily fit 100-120 when editing code, one limiting factor is side-by-side diffs, where readability is just as important for reviews.

For example, on this laptop screen, GitHub's diff wraps at around 77 chars.

image

https://github.com/jazzband/tablib/pull/430/files#diff-d6e3b675c1b812304a6d688c5cd1eb58R101

image

https://github.com/jazzband/tablib/pull/430/files#diff-d6e3b675c1b812304a6d688c5cd1eb58R138

So I'd prefer it somewhere in the lower range of 88-100, if possible.

@hugovk
Copy link
Member Author

hugovk commented Nov 26, 2019

Let's not worry about Black for now, it's not essential.

@hugovk hugovk closed this Nov 26, 2019
@hugovk hugovk deleted the black branch November 26, 2019 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants