Skip to content

[report-converter] Read the column from Pyflakes output - #5222

Open
ranjithguggilla wants to merge 1 commit into
Ericsson:masterfrom
ranjithguggilla:fix/pyflakes-column
Open

ranjithguggilla wants to merge 1 commit into
Ericsson:masterfrom
ranjithguggilla:fix/pyflakes-column

Conversation

@ranjithguggilla

Copy link
Copy Markdown

Pyflakes has printed a column after the line number since 2.2.0. Releases 2.2.0 through 2.4.0 write file:line:col message, and 2.5.0 and later write file:line:col: message. The report-converter parser only matched the older file:line: message form, so with any Pyflakes from the last six years every report was stored at column 0 and the column number was left on the front of the message:

$ pyflakes files/simple.py          # pyflakes 4.1.0
files/simple.py:5:12: undefined name 'self'
# report-converter -t pyflakes: line 5, column 0, message "12: undefined name 'self'"

The parser now accepts an optional column after the line number and uses it when it is present. Output that has no column is parsed exactly as before, so those reports keep the same column, message, and hash.

Regression tests use real output of both column formats (pyflakes 4.1.0 and pyflakes 2.4.0) for the existing files/simple.py fixture, and they share one expected plist. The existing column-less simple.out case is unchanged.

Pyflakes reports already stored from current Pyflakes will get new report IDs once the column and message are correct. The report hash includes both fields, so a stored report from new-format output shows up once as resolved and once as new. Output without a column keeps its report IDs.

Local checks on Python 3.11, with the pinned dev tools (pytest 7.3.1, pycodestyle 2.12.0, pylint 3.2.7):

  • the Pyflakes parser tests pass, including the two new cases
  • make test_unit is 133 passed; the same five plist_to_html tests fail because make dep was not run and codemirror.LICENSE is missing
  • pycodestyle is clean, and pylint on the changed files is 10.00/10

Pyflakes prints the column number after the line number since version
2.2.0 ("file:line:col message"), and with a colon since 2.5.0
("file:line:col: message"). The parser only knew the older
"file:line: message" format, so for current Pyflakes every report got
column 0 and a message that starts with the column number, for example
"12: undefined name 'self'".

Match an optional column after the line number and use it when present.
Output without a column is parsed as before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant