Skip to content
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

Multiple statements on one line reported when using NamedTuple #601

Closed
asottile opened this issue Apr 3, 2021 · 2 comments
Closed

Multiple statements on one line reported when using NamedTuple #601

asottile opened this issue Apr 3, 2021 · 2 comments

Comments

@asottile
Copy link
Member

asottile commented Apr 3, 2021

In GitLab by @michaeldel on Jul 23, 2017, 17:00

Please describe how you installed Flake8

$ pip install -U flake8

Please provide the exact, unmodified output of flake8 --bug-report

{
  "dependencies": [
    {
      "dependency": "setuptools",
      "version": "36.0.1"
    }
  ],
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.6.1",
    "system": "Linux"
  },
  "plugins": [
    {
      "plugin": "mccabe",
      "version": "0.6.1"
    },
    {
      "plugin": "pycodestyle",
      "version": "2.3.1"
    },
    {
      "plugin": "pyflakes",
      "version": "1.5.0"
    }
  ],
  "version": "3.3.0"
}

Please describe the problem or feature

It seems that using field names containing keywords (such as for or while) in a typing.NamedTuple makes flake8 report this error E701 multiple statements on one line (colon)

If this is a bug report, please explain with examples (and example code) what you expected to happen and what actually happened.

Here is a working example showing the bug:

from typing import NamedTuple


class MyNamedTuple(NamedTuple):
    domestic: str
    foreign: str
    fareign: str
    whiley: str


if __name__ == '__main__':
    mnt = MyNamedTuple('dom', 'for', 'far', 'whi')
    print(mnt)

I can run it without any problem:

$ python script.py
MyNamedTuple(domestic='dom', foreign='for', fareign='far', whiley='whi')

However, flake8 reports two errors, concerning the fields containing for and while in that case:

$ flake8 script.py
flake8_namedtuple.py:6:12: E701 multiple statements on one line (colon)
flake8_namedtuple.py:8:11: E701 multiple statements on one line (colon)
@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @sigmavirus24 on Jul 24, 2017, 04:09

This is actually a bug in pycodestyle reported here:

And they've both been fixed but need an upstream release.

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @sigmavirus24 on Jul 24, 2017, 04:09

closed

@asottile asottile closed this as completed Apr 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant