pythonstyle: Fix suppression support; improve SyntaxError reporting; Only report each nit once

Review Request #3647 - Created April 4, 2016 and submitted

Nick Howard (Twitter)
3128, 3139
benjyw, gmalmquist, jsirois, molsen

This patch cleans up a number of issues I encountered while trying to fix suppression support in the Python style checks.

  • The suppression option wasn't working as expected because the file names passed to it were changed from relative to absolute. This moves parsing into get_nits so that it has access to the relative file path.
  • SyntaxErrors show only the default error message without any source context. This patch adds source context display to syntax errors.
  • Multiline nits are counted and outputed once for each line they contain. This changes it so that they are only counted and logged once.

The one change I want to call out specifically is that I changed Nit so that it doesn't know about the PythonFile anymore. I did this so that I could make a nit for SyntaxErrors without introducing a variant of PythonFile for syntactically incorrect Python files.

If there are external plugins that rely on Nit's current structure, this may break them.

Wrote a test covering using suppression, and fixed it. Then added more tests around syntax error handling and fixed those.

After doing some testing, I noticed the multi-line display issue and fixed that as well following the same process.

CI away on the PR.


  • 0
  • 2
  • 1
  • 3
Description From Last Updated
Matt Olsen
Stu Hood
Nick Howard (Twitter)
Matt Olsen
Matt Olsen
Benjy Weinberger
Nick Howard (Twitter)
Review request changed

Status: Closed (submitted)

Change Summary:

Eric Ayers

FYI, I'm getting an exception I think is related to this change after upgrading to 0.0.81. See