black: pylint: [pylint] C0330:Wrong hanging indentation before block (add 4 spaces).
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:
def doc_dl_job(
doc_ids,
dl_folder,
root_url=None,
api_username=None,
api_password=None,
updatedcontent_root_url=None,
):
'''Download documents by list of doc ids.'''
api = API(api_username, api_password, root_url=root_url)
Pylint complains about all lines with function arguments.
Command: black -l 100 testfile.py
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 7
- Comments: 16
Commits related to this issue
- discr sys fits/service mods, bugfixes, docstrings, code formatting, remove proprietary code (#514) * core/binning.py * `is_bin_spacing_log` check always using `allclose` for FP32 compatibility * ... — committed to icecube/pisa by jllanfranchi 6 years ago
- discr sys fits/service mods, bugfixes, docstrings, code formatting, remove proprietary code (#514) * core/binning.py * `is_bin_spacing_log` check always using `allclose` for FP32 compatibility * ... — committed to icecube/pisa by jllanfranchi 6 years ago
- Reformat Python files with black 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 i... — committed to GerritCodeReview/k8s-gerrit by dpursehouse 5 years ago
- Ignore __init__ and ignore pylint bug Pylint complains on syntax that black is setting up, https://github.com/psf/black/issues/48 — committed to berland/fmu-ensemble by berland 5 years ago
- Codequality (#48) * Ignore __init__ and ignore pylint bug Pylint complains on syntax that black is setting up, https://github.com/psf/black/issues/48 * Fix pylint issues * Improve pylint ... — committed to equinor/fmu-ensemble by berland 5 years ago
- Ignore C0330 caused by `black` formatter Ignore C0330 (wrong indentation function argument). More information can be found here: https://github.com/psf/black/issues/48. — committed to Dmitrii-I/sportmonks by Dmitrii-I 5 years ago
- disable pylint bad-continuation message It gives false positives see https://github.com/psf/black/issues/48 In particular: x = {'bar': ['foo'], } — committed to mlippert/analyze-data by mlippert 5 years ago
- Disable pylint's bad-continuation check, due to https://github.com/PyCQA/pylint/issues/289 and https://github.com/psf/black/issues/48 — committed to mytardis/mydata-python by jameswettenhall 4 years ago
- Pylint: Disable bad-continuation Pylint seems to prefer double indents (8 spaces) for method argument lists, while black prefers single indents (4 spaces). Since black does the formatting for us, no ... — committed to pastelmind/d2txt by pastelmind 4 years ago
- Pylint: Disable bad-continuation Pylint seems to prefer double indents (8 spaces) for method argument lists, while black prefers single indents (4 spaces). Since black does the formatting for us, no ... — committed to pastelmind/d2txt by pastelmind 4 years ago
- Pylint: Disable bad-continuation Pylint seems to prefer double indents (8 spaces) for method argument lists, while black prefers single indents (4 spaces). Since black does the formatting for us, no ... — committed to pastelmind/d2txt by pastelmind 4 years ago
- Pylint: Disable bad-continuation Pylint seems to prefer double indents (8 spaces) for method argument lists, while black prefers single indents (4 spaces). Since black does the formatting for us, no ... — committed to pastelmind/d2txt by pastelmind 4 years ago
- Prevent bad-continuation warning This is caused by a disagreement between black and pylint on indentation of multiple chained conditions in an if-statment. See: https://github.com/psf/black/issues/4... — committed to pastelmind/slack-craps by pastelmind 4 years ago
- Refresh pylintrc while keeping some old settings 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-line... — committed to GenericMappingTools/pygmt by weiji14 4 years ago
- Disable conflicting rule between black and pylint See : https://github.com/psf/black/issues/48 https://github.com/PyCQA/pylint/issues/289 — committed to ChauffeurPrive/nestor-api by chris-verclytte 4 years ago
- Disable conflicting rule between black and pylint See : https://github.com/psf/black/issues/48 https://github.com/PyCQA/pylint/issues/289 — committed to ChauffeurPrive/nestor-api by chris-verclytte 4 years ago
- Disable conflicting rule between black and pylint See : psf/black#48 PyCQA/pylint#289 — committed to tkoyama010/pyvistaqt by tkoyama010 4 years ago
- pylint: Disable bad-continuation for compatibility with black See https://github.com/psf/black/issues/48 — committed to buzz/devilspy by buzz 4 years ago
- š Add pylint in CI #39 (#40) * 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 work... — committed to pyvista/pyvistaqt by tkoyama010 4 years ago
For the next person: This is a known issue and was reported to pylint in 2014, https://github.com/PyCQA/pylint/issues/289
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.
@yech1990 this is clearly explained in the readme:
Please read the docs. There will be no flags to control formatting. This pylint warning is wrong, it should be disabled.
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 https://github.com/PyCQA/pylint/issues/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.
Itās possible, but there is not really a need to do so. Just update to
pylint>=2.6.0, they have removed āC0330ā entirely.See https://github.com/PyCQA/pylint/issues/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
Thanks for your report but this isnāt something we will change in 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
):at the same indent level asdef. Code folding is also easier with this style (just fold based on indentation).vs.
@egabrum Thatās just a criticism of whatever youāre using for code folding, not an inherent limitation of the formatting.
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) ⦠š¦
@mrcoles that sounds like you should report it to VSCode (or whatever plugin youāre using), not to Black.