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
NamedTuple defined with Python 3.6 type hints is reported with E701 #635
Comments
Can you please provide the version of pycodestyle and the version of python it's installed on? |
I am running |
Using the latest version of pep8 available from PyPI.
I get that you might not always be able to keep up with changes in Python, but this is super annoying since pep8 apparently doesn't support By comparison, neither flake8 nor pylint have any problems with the code example above. |
pep8 has been renamed to pycodestyle. Please try the latest release of pycodestyle instead of using pep8. That's why flake8 works (it uses pycodestyle). |
Ah, fair enough, my bad. I mistakenly thought the old pep8 executable was the same version as pycodestyle, which is clearly not the case. With that said, pycodestyle 2.3.1 works fine for my example, but not for the code @futursolo reported. Merging the two examples:
I.e., EDIT: Ah, I get it; this is about variable names beginning with keywords that would normally signify an indented block. If the variable names begin with |
If a Python 3 class variable begins with an indent keyword, i.e., class Class: with_foo: int pycodestyle will erroneously output the error 'E701 multiple statements on one line'. This patch tightens the check so that even variables beginning with indent keywords are allowed. Resolves PyCQA#635
I would say the problem is in the regex on this line. Changing it to STARTSWITH_INDENT_STATEMENT_REGEX = re.compile(
r'^\s*({0})'.format('|'.join((s + ' ').replace(' ', r'\s+') for s in (
'def', 'async def',
'for', 'async for',
'if', 'elif', 'else:',
'try:', 'except', 'finally:',
'with', 'async with',
'class',
'while',
)))
) will still make it pass the existing tests. |
Solved by #640 |
I'm having the same problem with $> python --version
Python 3.7.0
$> flake8 --version
3.5.0 (mccabe: 0.6.1, pycodestyle: 2.3.1, pyflakes: 1.6.0) CPython 3.7.0 on Darwin """Docstring"""
from typing import Dict
class Foo(NamedTuple):
"""Docstring."""
forty_eight_hours_ago: str
format_params: Dict[str, str] $> flake8 test.py
test.py:6:9: E701 multiple statements on one line (colon)
test.py:7:9: E701 multiple statements on one line (colon) |
I am also seeing this with Python 3.6.3, flake8 3.5.0 and pycodestyle being 2.3.1 |
It's to avoid an false positive flake8 throws with pycodestyle 2.3.1 in travis: https://travis-ci.org/raiden-network/raiden/jobs/414275990 There is an issue in the upstream repo of pycodestyle for this: PyCQA/pycodestyle#635 [ci integration]
This issue is resolved by a later version of pycodestyle. But flake8 pinned the version of pycodestyle to this bugged version. |
We get a false positive flake8 throws with pycodestyle 2.3.1 in travis: https://travis-ci.org/raiden-network/raiden/jobs/414275990 There is an issue in the upstream repo of pycodestyle for this: PyCQA/pycodestyle#635 [ci integration]
Yeah I figured it out in the meantime. Thanks for the hint @futursolo. Added E701 to the ignored warnings for now for our project and waiting till flake8 makes another release. |
We get a false positive flake8 throws with pycodestyle 2.3.1 in travis: https://travis-ci.org/raiden-network/raiden/jobs/414275990 There is an issue in the upstream repo of pycodestyle for this: PyCQA/pycodestyle#635 [ci integration]
With a new version of flake8 we can now stop ignoring E701 that was introduced to this bug: PyCQA/pycodestyle#635
With a new version of flake8 we can now stop ignoring E701 that was introduced to this bug: PyCQA/pycodestyle#635
With a new version of flake8 we can now stop ignoring E701 that was introduced to this bug: PyCQA/pycodestyle#635
NamedTuple defined with Python 3.6 type hints is reported with E701 when the name of the members in the tuple starts with indent keywords.
Examples:
When testing the code above against
pycodestyle --show-source test.py
, it shows:The text was updated successfully, but these errors were encountered: