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

physical line plugins aren't passed every physical line when an expression contains a multiline string #1534

Closed
asottile opened this issue Jan 21, 2022 · 0 comments · Fixed by #1536

Comments

@asottile
Copy link
Member

how did you install flake8?

$ pip install git+https://github.com/pycqa/flake8@ca573a7ccf2d4a1c7df0b577bb6d3455c941e828
Collecting git+https://github.com/pycqa/flake8@ca573a7ccf2d4a1c7df0b577bb6d3455c941e828
  Cloning https://github.com/pycqa/flake8 (to revision ca573a7ccf2d4a1c7df0b577bb6d3455c941e828) to /tmp/pip-req-build-lh3_65yl
  Running command git clone --filter=blob:none -q https://github.com/pycqa/flake8 /tmp/pip-req-build-lh3_65yl
  Running command git rev-parse -q --verify 'sha^ca573a7ccf2d4a1c7df0b577bb6d3455c941e828'
  Running command git fetch -q https://github.com/pycqa/flake8 ca573a7ccf2d4a1c7df0b577bb6d3455c941e828
  Resolved https://github.com/pycqa/flake8 to commit ca573a7ccf2d4a1c7df0b577bb6d3455c941e828
  Preparing metadata (setup.py) ... done
Requirement already satisfied: mccabe<0.7.0,>=0.6.0 in ./venv/lib/python3.8/site-packages (from flake8==4.0.1) (0.6.1)
Requirement already satisfied: pycodestyle<2.9.0,>=2.8.0 in ./venv/lib/python3.8/site-packages (from flake8==4.0.1) (2.8.0)
Requirement already satisfied: pyflakes<2.5.0,>=2.4.0 in ./venv/lib/python3.8/site-packages (from flake8==4.0.1) (2.4.0)
Building wheels for collected packages: flake8
  Building wheel for flake8 (setup.py) ... done
  Created wheel for flake8: filename=flake8-4.0.1-py2.py3-none-any.whl size=61251 sha256=96363641001fa7562bbd594af37564c697971950775dcd9335e7d7f94cad3238
  Stored in directory: /home/asottile/.cache/pip/wheels/9b/f3/37/5b6c870430baba34a27d437055cfdb1b431514495819e6fd0b
Successfully built flake8
Installing collected packages: flake8
  Attempting uninstall: flake8
    Found existing installation: flake8 4.0.1
    Uninstalling flake8-4.0.1:
      Successfully uninstalled flake8-4.0.1
Successfully installed flake8-4.0.1

unmodified output of flake8 --bug-report

{
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.8.10",
    "system": "Linux"
  },
  "plugins": [
    {
      "plugin": "mccabe",
      "version": "0.6.1"
    },
    {
      "plugin": "pycodestyle",
      "version": "2.8.0"
    },
    {
      "plugin": "pyflakes",
      "version": "2.4.0"
    }
  ],
  "version": "4.0.1"
}

describe the problem

what I expected to happen

I expect to get two physical lines outputted such as:

$ flake8 t.py
'no_flake8_e501_error = "My line longer than 80 chars xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + """\n'
'"""\n'

sample code

(t.py)

no_flake8_e501_error = "My line longer than 80 chars xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + """
"""

(plug.py)

def plug(physical_line: str):
    print(repr(physical_line))
    return
    yield

(setup.cfg)

[flake8:local-plugins]
extension =
    A=plug:plug
paths = .

commands ran

$ flake8 t.py
'"""\n'
'"""\n'
@asottile asottile added this to the 5.0.0 milestone Jul 30, 2022
openstack-mirroring pushed a commit to openstack/hacking that referenced this issue Apr 14, 2023
There is a bug [1] in older flake8 that we need to pick up. In
particular, Nova has at least one line longer than 80 characters in it
[2] because of that bug. Our own unit tests start breaking with the
new flake8, so we need to fix whitespace for one `if`, and start
calling flake8 with `--enable-extentions` to force flake8 to load
extensions decorated with @off_by_default.

[1] PyCQA/flake8#1534
[2] https://opendev.org/openstack/nova/src/commit/5c32d5efe1e1aece48b680474617113c61a248d5/nova/image/glance.py#L392

Change-Id: I7799049924b5a2cde867c88c03154c36831c9670
openstack-mirroring pushed a commit to openstack/openstack that referenced this issue Apr 14, 2023
* Update hacking from branch 'master'
  to 3fde1e570a064ce38e7c512b16610ff4650426c3
  - Bump flake8 to 5.0 to pick up fixes
    
    There is a bug [1] in older flake8 that we need to pick up. In
    particular, Nova has at least one line longer than 80 characters in it
    [2] because of that bug. Our own unit tests start breaking with the
    new flake8, so we need to fix whitespace for one `if`, and start
    calling flake8 with `--enable-extentions` to force flake8 to load
    extensions decorated with @off_by_default.
    
    [1] PyCQA/flake8#1534
    [2] https://opendev.org/openstack/nova/src/commit/5c32d5efe1e1aece48b680474617113c61a248d5/nova/image/glance.py#L392
    
    Change-Id: I7799049924b5a2cde867c88c03154c36831c9670
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant