Pycodestyle: E701 with type annotation (false positive)

Created on 26 Sep 2017  路  6Comments  路  Source: PyCQA/pycodestyle

This line is marked as

E701 statements on one line (colon)

for_photo: int = photo * cls.price_for_photo

but variable value assignment works fine:

additional_info: str = self.additional_info

I want to disable too complex variable assignment with type annotation but not multiple statements on one line. How I can achieve it?

Most helpful comment

Is there a timeline for releasing it?

All 6 comments

Hi, I think you'll find that the real reason for your issue is not the value you're assigning, but rather that your variable name starts with for, a keyword. See #686 for my report.

This was fixed in #640, but hasn't been released yet.

Is there a timeline for releasing it?

Seeing this problem on v2.3.1.

Looked at changelog and saw https://github.com/PyCQA/pycodestyle/blob/master/CHANGES.txt#L35 which sounds like it was 'fixed'. But still see the same issue on 2.3.0.

https://github.com/PyCQA/pycodestyle/commits/2.3.1 was last updated on 1-30-17
https://github.com/PyCQA/pycodestyle/pull/640 was merged 6-9-17

Can we please get this fix released?

I have the same problem with 2.3.1 version. When I run the command flake8 --exclude=docs/*,*migrations*, --ignore=E501 for the file bellow...

test.py

class SomeClass:
    some_ok_attr: str
    with_error: str
    another_ok_attr: str

The following error is generated:
test.py:3:15: E701 multiple statements on one line (colon)

Something is wrong when an attribute has the h letter and its is typed

Still seeing it with flake8 3.5.0 (pycodestyle 2.3.1). Both E701 and E704.

Was this page helpful?
0 / 5 - 0 ratings