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
pylint: [pylint] C0330:Wrong hanging indentation before block (add 4 spaces). #48
Comments
This is a pylint problem. Pylint thinks that the arguments aren't separated visually from the body of the function. They are, by the line with the colon. |
Thanks for your report but this isn't something we will change in Black. |
@ambv The result of |
@yech1990 this is clearly explained in the readme:
|
I'm also seeing the same pylint issue: |
Please read the docs. There will be no flags to control formatting. This pylint warning is wrong, it should be disabled. |
For the next person: |
…emove proprietary code (#514) * core/binning.py * `is_bin_spacing_log` check always using `allclose` for FP32 compatibility * core/base_stage.py * black formatting only * core/pi_stage.py * add some method docstrings (not all added / totally useful, but should be better now) * PISA and black formatting * core/pipeline.py * fix regression which removed raising AttributeError when `__getattr__` is called with non-existent stage / non-existent attr * black formatting * core/stage.py * black formatting * utils/format.py * binary prefixes explicitly fail if values < 0 * setup.py * add `fit_discrete_sys_nd.py` as `pisa-fit_discrete_sys_nd` as a script installed by PISA * stages/data/icc.py * icc params documented with actual params used * stages/xsec/genie_sys.py * docstring fixups * black formatting * stages/discr_sys/pi_hyperplanes.py * fixup, augment docstrings * fit_cfg able to modify specified pipeline config incl. an apply_to_all_sets section * fix logging outputs for modifications to in-mem pipeline config(s) * do as much stuff as possible to get to errors faster if they exist * add units handling for interpreting values of hyperplane fit params * **TODO** for now, all pi_hyperplanes binning checks are disabled (TODO: enable but check at FP32 precision!) * misc fixups * black formatting * scripts/fit_discr_sys_nd.py * add units handling for hyperplane fit params * record more info to fit json file (binning (at top level), fit cfg path and text, pipeline cfg paths and texts, hyperplane fit param units) * allow modifying pipeline configs specified in fit configs * document the discrete fit config file format, "features" (units, modifying a pipeline config) at the top of the script * code cleanups * black formatting * pi_simple * Remove proprietary code but can use that code from fridge (error message added to inform user of the path needed in PISA_RESOURCES if the code cannot be found) * Black formatting, pylint ignores added where appropriate * pylintrc * add C0330 as per psf/black#48
…emove proprietary code (#514) * core/binning.py * `is_bin_spacing_log` check always using `allclose` for FP32 compatibility * core/base_stage.py * black formatting only * core/pi_stage.py * add some method docstrings (not all added / totally useful, but should be better now) * PISA and black formatting * core/pipeline.py * fix regression which removed raising AttributeError when `__getattr__` is called with non-existent stage / non-existent attr * black formatting * core/stage.py * black formatting * utils/format.py * binary prefixes explicitly fail if values < 0 * setup.py * add `fit_discrete_sys_nd.py` as `pisa-fit_discrete_sys_nd` as a script installed by PISA * stages/data/icc.py * icc params documented with actual params used * stages/xsec/genie_sys.py * docstring fixups * black formatting * stages/discr_sys/pi_hyperplanes.py * fixup, augment docstrings * fit_cfg able to modify specified pipeline config incl. an apply_to_all_sets section * fix logging outputs for modifications to in-mem pipeline config(s) * do as much stuff as possible to get to errors faster if they exist * add units handling for interpreting values of hyperplane fit params * **TODO** for now, all pi_hyperplanes binning checks are disabled (TODO: enable but check at FP32 precision!) * misc fixups * black formatting * scripts/fit_discr_sys_nd.py * add units handling for hyperplane fit params * record more info to fit json file (binning (at top level), fit cfg path and text, pipeline cfg paths and texts, hyperplane fit param units) * allow modifying pipeline configs specified in fit configs * document the discrete fit config file format, "features" (units, modifying a pipeline config) at the top of the script * code cleanups * black formatting * pi_simple * Remove proprietary code but can use that code from fridge (error message added to inform user of the path needed in PISA_RESOURCES if the code cannot be found) * Black formatting, pylint ignores added where appropriate * pylintrc * add C0330 as per psf/black#48
Black [1] is the "uncompromising Python code formatter". Caveats: - The code is reformatted with a 4 column indentation, contrary to the currently used 2 column indentation. Both the Google Python Style Guide [2] and PEP-8 [3] specify a 4 column indentation, so this change should be OK. The pylint configuration is adjusted to this. - Due to an issue with hanging indentation [4], pylint C0330 is disabled. - By default it wraps lines at 88 columns. This can be configured, but for now it is left at default. - At least Python 3.6 is required to run the formatter. [1] https://github.com/psf/black [2] https://github.com/google/styleguide/blob/gh-pages/pyguide.md#s3.4-indentation [3] https://www.python.org/dev/peps/pep-0008/#indentation [4] psf/black#48 Change-Id: I615852cb47a268ef3a05e6fdb3c57cdc3de8d42e
Pylint complains on syntax that black is setting up, psf/black#48
* Ignore __init__ and ignore pylint bug Pylint complains on syntax that black is setting up, psf/black#48 * Fix pylint issues * Improve pylint scores * One line was too long
In defense of pylint, to be honest, it's annoying that to collapse a function with Black's formatting, you have to collapse the definition AND then the function body (2 steps) ... :-( |
Ignore C0330 (wrong indentation function argument). More information can be found here: psf/black#48.
It gives false positives see psf/black#48 In particular: x = {'bar': ['foo'], }
@egabrum That's just a criticism of whatever you're using for code folding, not an inherent limitation of the formatting. |
I think there is a misunderstanding in what pylint is saying here: Black does not add enough indent to comply with the indent recommendations in pep8 regarding function definitions:
I do understand that black puts each parameter on a separate line on purpose (and I love the idea), but I think it should be adding an extra level of indent to the parameters for increased readability, like the following:
As for the aforementioned bug report pylint-dev/pylint#289 in the pylint repository: That one is about indents for if-statements and there is still (even six years later) an ongoing discussion on the validity of that bug report (i.e. on how to interpret pep8 exactly). Guido seems to think that black violates pep8 in that regard, though: https://discuss.python.org/t/pep-8-clarify-if-multiline-argument-list-with-a-closing-on-a-separate-line-is-acceptable/2948/7 So I wouldn't consider this a hard bug, but a change I would love to see nonetheless, as it makes code more readable IMHO and makes black-formatted code a bit more pep8-compliant. |
Run v2.5.3 of pylint: `pylint --generate-rcfile > .pylintrc`, and then manually keeping some old PyGMT specific settings. E.g. jobs=4; max-module-lines=2000; max-args=10; max-attributes=10; good-names=i,j,k,ex,Run,_,w,e,s,n,x,y,z. Add back 'attribute-defined-outside-init' and 'bad-continuation' to the disable list, the latter is to fit in with black (see psf/black#48).
Small aside—disabling def foo(
bar: str
):
| Version: 1.46.1 |
@mrcoles that sounds like you should report it to VSCode (or whatever plugin you're using), not to Black. |
I think the solution @soulmerge suggested is a good one. He's right about black not conforming to PEP8 in this way. I also think visually it is easier to see what is going on without the
vs.
|
At the expense of commenting on a closed issue, I think the point of the others is that PEP8 is actually ambiguous here and does not explicitly disallow the formatting path chosen by black (just one that is quite similar). In either case one begins to argue about interpretations, which frankly is a flaw in the design of PEP8. |
* Add pylint in CI #39 * Improve rating to 8.87/10 * Fix codespell conf * Install dependencies * Setup python first * Use python 3.6 * Fix workflow * Restore workflow * Update .github/workflows/pythonpackage.yml * Fix C0103: invalid-name * Fix C0103 invalid-name * Add pylint Makefile target * Fix C0103 invalid-name * ♻️ fix by pylint * Fix Makefile * Move dragEnterEvent to function * Fix pylint error * Fix W0611 unused-import * Fix W0613: unused-argument * Fix isort * Revert of comment * Fix unnecessary-lambda * Fix unnecessary-lambda * Fix invalid name * Fix unused variable * Disable conflicting rule between black and pylint See : psf/black#48 pylint-dev/pylint#289 * Fix reimported (W0404) * Fix C0412 (ungrouped-imports) * Fix missing-module-docstring * Fix too-many-arguments * Fix broad-except * Fix invalid-name * Fix disable to name * Fix too-many-instance-attributes * Fix pylint * Fix black * Fix invalid-name * Fix too-many-arguments * Update pyvistaqt/window.py * Update pyvistaqt/dialog.py * Fix pylint * Fix too-few-public-method * Fix too-few-public-methods * Remove enable F401 * Revert "Remove enable F401" This reverts commit c937bc5. * Fix attribute-defined-outside-init * Fix too-few-public-methods * Fix unsubscriptable-object * Fix unsubscriptable-object * Fix pycodestyle * Fix isort * Fix typo * Update pyvistaqt/plotting.py * Fix unnecessary-lambda * Update dialog.py * Update pyvistaqt/dialog.py * Update pyvistaqt/dialog.py * Update pyvistaqt/dialog.py * Update pyvistaqt/dialog.py * Fix invalid-name * Update pyvistaqt/dialog.py * Update pyvistaqt/dialog.py * Update pyvistaqt/dialog.py * Fix unused-argument * Fix at least two spaces before inline comment * Update pyvistaqt/plotting.py * Update pyvistaqt/plotting.py * Update pyvistaqt/plotting.py * Update pyvistaqt/plotting.py * Update pyvistaqt/plotting.py * Update pyvistaqt/plotting.py * Update pyvistaqt/plotting.py * Fix invalid-name * Update plotting.py * Update plotting.py * Fix no-self-use * Fix attribute-defined-outside-init * Fix attribute-defined-outside-init * Fix attribute-defined-outside-init * Fix E261 at least two spaces before inline comment * Update pyvistaqt/plotting.py * Update pyvistaqt/plotting.py * Update pyvistaqt/plotting.py * Update pyvistaqt/plotting.py * Update pyvistaqt/plotting.py * Update pyvistaqt/plotting.py * Update pyvistaqt/plotting.py * Fix attribute-defined-outside-init * Update pyvistaqt/window.py * Fix no cover * Update pyvistaqt/plotting.py * Update pyvistaqt/plotting.py * Fix pylint * Restore imports and adds docstrings * Deal with PyQt5 ungrouped-imports * Make isort * Add docstring Co-authored-by: Guillaume Favelier <guillaume.favelier@gmail.com>
If you agree with solution purposed by @mrcoles of Disabling this specific Pylint validation and agrees with Black's approach of identation, it is possible to run: pylint <path> --disable C0330 Then In VSCode:If you use pylint as linter in VSCode, you can add this to Pylint Args Or, add it to your
|
It's possible, but there is not really a need to do so. Just update to See pylint-dev/pylint#289 and the 2.6.0 release notes:
http://pylint.pycqa.org/en/latest/whatsnew/changelog.html#what-s-new-in-pylint-2-6-0 |
C0326 and C0330 no longer exist or cause problems: - pylint-dev/pylint#2041 - psf/black#48 (comment)
…spaces)' This is a known pylint bug. More information can be found here: psf/black#48
This is a known pylint bug. More information can be found here: psf/black#48
Operating system: Win7 x64
Python version: 3.6.0
Black version: black==18.3a3 installed from pypi into venv
Does also happen on master:
Code:
Pylint complains about all lines with function arguments.
Command:
black -l 100 testfile.py
The text was updated successfully, but these errors were encountered: