-
Notifications
You must be signed in to change notification settings - Fork 749
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
E203: False positive "whitespace before ':' " on list slice. #373
Comments
I took a look at the code and it looks like the function extraneous_whitespace This is confirmed in the doc string for the function, showing that E203 it covers these cases: Looking at the testsuite E20.py confirmed that it is not accounting for legitimate uses of this case. |
This needs to be cleaned up A LOT but here is a prototype of a potential fix(very incomplete but it is a workable idea) Please keep in mind this was a quick very incomplete prototype.
|
So I've been hacking on this for some time, and I don't know how to approach this without tokenizing. The wall I'm hitting is that the rules are context sensitive. I've managed to hack the linter enough that it handles expressions inside I have some code that somewhat works, but I'd be interested in some more guidance on how to tackle this. |
Hi @vodik, you can add a parameter |
this is now triggered by black doing the "right" thing - psf/black#279 |
@RonnyPfannschmidt I'd be happy to merge a PR that fixes this case |
@sigmavirus24 i#ll takea short look if i can figure a quickfix |
no quickfix for this one :( |
Facing the same issue: - attr_name = adapter[last_dot + 1:]
+ attr_name = adapter[last_dot + 1 :] |
As a temporary workaround,
|
i simply disabled the check, as black is making those bits correct in all cases |
becaues of this bug: PyCQA/pycodestyle#373
Using black's default line length of 88. Black follows the PEP8 standard more closely than pycodestyle does (as used in the flake8 checks) so must disable E203 until this is fixed: PyCQA/pycodestyle#373
Using black's default line length of 88. Black follows the PEP8 standard more closely than pycodestyle does (as used in the flake8 checks) so must disable E203 until this is fixed: PyCQA/pycodestyle#373
* The default behaviour of pydocstyle is to ignore "test_" files when given a directory to check. Follow its example and ignore "test_" files in the invocation we use too. * Ignore pycodestyle "E203" warnings - sometimes they are spurious (PyCQA/pycodestyle#373).
* The default behaviour of pydocstyle is to ignore "test_" files when given a directory to check. Follow its example and ignore "test_" files in the invocation we use too. * Ignore pycodestyle "E203" warnings - sometimes they are spurious (PyCQA/pycodestyle#373).
What: 1. Add exception for E203 whitespace before ':' 2. Ignore use of bad variable name "l" 3. Remove unused import Why: 1. There seems to be a discrepancy between the use of ':' within a slice: PyCQA/pycodestyle#373. Since black can handle the whitespace regarding ':' for both in and out of slices, we ignore this error and trust black to format it. 2. Because l is comonly used in equations for density matrices
Is there a way to align the projects pycodestyle and black so that users no longer need to manually configure them to work on a common repo? This alignment is now more important given that black has been moved into an official python repo: https://github.com/python/black |
@cclauss did you mean aside from fixing this issue (#373 in pycodestyle)? Slightly tangental, but I wrote https://github.com/peterjc/flake8-black I had to document ignoring E203 as a workaround. |
fwiw the move into the From this:
|
E203 needs to be ignore due to a false positive alert for slicing. See. PyCQA/pycodestyle#373 (comment)
E203 needs to be ignore due to a false positive alert for slicing. See. PyCQA/pycodestyle#373 (comment)
E203 needs to be ignore due to a false positive alert for slicing. See. PyCQA/pycodestyle#373 (comment)
E203 needs to be ignore due to a false positive alert for slicing. See. PyCQA/pycodestyle#373 (comment)
E203 needs to be ignore due to a false positive alert for slicing. See. PyCQA/pycodestyle#373 (comment)
E203 needs to be ignore due to a false positive alert for slicing. See. PyCQA/pycodestyle#373 (comment)
E203 needs to be ignore due to a false positive alert for slicing. See. PyCQA/pycodestyle#373 (comment)
I still have this issue with When definining a string slice like this: my_string[my_string.rindex("/") + 1 : my_string.index(":")]
However, this should not apply to slices, as mentioned in https://www.python.org/dev/peps/pep-0008/#pet-peeves. Manually removing the spaces does not work in our case, as code formatting is done by |
…443) * added coverage.xml to .gitignore * Basic rewrite of the travis tests, with github actions * removed now obsolete travis config * Added bump2version and its config * moved flake8 config to setup.cfg * Formatted requirements with comments * Created test file for each country and moved corresponding tests there * Added pre-commit and a basic config containing black+its config * Added flake8 to pre-commit config and set flake8 to ignore E203 E203 needs to be ignore due to a false positive alert for slicing. See. PyCQA/pycodestyle#373 (comment) * Replaced flake8 tests with pre-commit ones, since flake8 is included * Updated workflow to use tests folder, upload coverage to coveralls.io and some minor fixes * Added pre-commit hook that adds encoding shebang to all files py27 compat * Added coverage config * Added tox+pytest config and added .tox to .gitignore * Added rst checking tools to pre-commit and fixed rst issues * Added workflow dispatch as an option to run the workflow * Removed py35 as was done in https://github.com/dr-prodigy/python-holidays/pull/402 * Added dependabot config to receive automatics update PR's for python runtime dependencies and used github-actions * Fixed pytest config quoting the addopts made them not being recognized properly * Replaced travis with github actions badge * Changed contributing guide to reflect changed tooling * Formatted setup.py again with black * Auto-format, Israel to_jd_gregorianyear fix * requirements_dev.txt review, Israel fixes, CHANGES+README.rst reviews * precommit tasks run * removed python 2.7 checks from github CI/CD scripts * flake8 config fixes * travis build toml dependency fix * removed duplicated flake8 tests from coverage config * old tests.py using new test classes * tests tree reviewed * tests cleanup (warn: coverage report -m needs fixing) * Fixed usage of coveralls with gh-action after 3.0.0 release * more recent tests re-applied - #404 * copyright 2021 * test tree refactoring, pytest running thru tests.py * Flake8 test removed, pyproject.toml cleanup * Added .gitaddtributes file to ensure consistent '\n' line ending for future commits * Added pre-commit hook to enforce '\n' lineending and applied it on all files * Copied files from 'holiday' and 'tests' over and ran 'pre-commit run -a' This should catch all changes on beta which were missing. I left changes which were added in the cleanup of 'unstable' e.g. 'holidays.utils.is_leap_year' 'test/countries/test_saudiarabia.py' was renamed to 'test/countries/test_saudi_arabia.py' to be consistent with 'holidays/countries/saudi_arabia.py' * is_leap_year removal Co-authored-by: s-weigand <[email protected]>
(massive thx+kudos to s-weigand) * added coverage.xml to .gitignore * Basic rewrite of the travis tests, with github actions * removed now obsolete travis config * Added bump2version and its config * moved flake8 config to setup.cfg * Formatted requirements with comments * Created test file for each country and moved corresponding tests there * Added pre-commit and a basic config containing black+its config * Added flake8 to pre-commit config and set flake8 to ignore E203 E203 needs to be ignore due to a false positive alert for slicing. See. PyCQA/pycodestyle#373 (comment) * Replaced flake8 tests with pre-commit ones, since flake8 is included * Updated workflow to use tests folder, upload coverage to coveralls.io and some minor fixes * Added pre-commit hook that adds encoding shebang to all files py27 compat * Added coverage config * Added tox+pytest config and added .tox to .gitignore * Added rst checking tools to pre-commit and fixed rst issues * Added workflow dispatch as an option to run the workflow * Removed py35 as was done in https://github.com/dr-prodigy/python-holidays/pull/402 * Added dependabot config to receive automatics update PR's for python runtime dependencies and used github-actions * Fixed pytest config quoting the addopts made them not being recognized properly * Replaced travis with github actions badge * Changed contributing guide to reflect changed tooling * Formatted setup.py again with black * Auto-format, Israel to_jd_gregorianyear fix * requirements_dev.txt review, Israel fixes, CHANGES+README.rst reviews * precommit tasks run * removed python 2.7 checks from github CI/CD scripts * flake8 config fixes * travis build toml dependency fix * removed duplicated flake8 tests from coverage config * old tests.py using new test classes * tests tree reviewed * tests cleanup (warn: coverage report -m needs fixing) * Fixed usage of coveralls with gh-action after 3.0.0 release * more recent tests re-applied - #404 * copyright 2021 * test tree refactoring, pytest running thru tests.py * Flake8 test removed, pyproject.toml cleanup * Added .gitaddtributes file to ensure consistent '\n' line ending for future commits * Added pre-commit hook to enforce '\n' lineending and applied it on all files * Copied files from 'holiday' and 'tests' over and ran 'pre-commit run -a' This should catch all changes on beta which were missing. I left changes which were added in the cleanup of 'unstable' e.g. 'holidays.utils.is_leap_year' 'test/countries/test_saudiarabia.py' was renamed to 'test/countries/test_saudi_arabia.py' to be consistent with 'holidays/countries/saudi_arabia.py' * is_leap_year removal Co-authored-by: s-weigand <[email protected]>
noqa issue : PyCQA/pycodestyle#373
Any news? |
@jeffteixeira do you see a comment or resolution here? bumping the thread does not help |
I've encountered the problem in the following code:
However, PEP8 chapter https://www.python.org/dev/peps/pep-0008/#whitespace-in-expressions-and-statements handles this as good style:
The text was updated successfully, but these errors were encountered: