Skip to content

Instantly share code, notes, and snippets.

@andialbrecht
Created April 13, 2011 07:26
Show Gist options
  • Save andialbrecht/917126 to your computer and use it in GitHub Desktop.
Save andialbrecht/917126 to your computer and use it in GitHub Desktop.
Regex to parse pylint output
# Regex to extract error messages from "pylint -f parseable" output
import re
P_PYLINT_ERROR = re.compile(r"""
^(?P<file>.+?):(?P<line>[0-9]+):\ # file name and line number
\[(?P<type>[a-z])(?P<errno>\d+) # message type and error number, e.g. E0101
(,\ (?P<hint>.+))?\]\ # optional class or function name
(?P<msg>.*) # finally, the error message
""", re.IGNORECASE|re.VERBOSE)
@alexflint
Copy link

Here is what I used in go:

var linterRegex = regexp.MustCompile(`^(?P<file>.+?):(?P<line>[0-9]+): \[(?P<code>[A-Z][0-9]+)\((?P<key>.*)\), \] (?P<msg>.*)`)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment