Skip to content

Instantly share code, notes, and snippets.

@lbolla
Created March 8, 2019 15:59
Show Gist options
  • Save lbolla/f81def50503998e6582368b59f98b03f to your computer and use it in GitHub Desktop.
Save lbolla/f81def50503998e6582368b59f98b03f to your computer and use it in GitHub Desktop.
Example for pycheckers bug report msherry/flycheck-pycheckers#33
import re
line = 'filename.py:24: error: Dict entry 0 has incompatible type "str": "str"; expected "int": "str"'
output_matcher = re.compile(
r'(?P<filename>[^:]+):'
r'(?P<line_number>[^:]+):'
r'((?P<column_number>[^:]+):)?' # Column number is optional, depending on mypy options
r' (?P<level>[^:]+):'
r' (?P<description>.+)$')
m = output_matcher.match(line)
print(m.groupdict())
output_matcher = re.compile(
r'(?P<filename>[^:]+):'
r'(?P<line_number>\d+):'
r'((?P<column_number>\d+):)?' # Column number is optional, depending on mypy options
r' (?P<level>[^:]+):'
r' (?P<description>.+)$')
m = output_matcher.match(line)
print(m.groupdict())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment