diff --git a/mypy_baseline/_error.py b/mypy_baseline/_error.py index 5c50843..72aa6cf 100644 --- a/mypy_baseline/_error.py +++ b/mypy_baseline/_error.py @@ -20,6 +20,14 @@ (?:\s\s\[(?P[a-z-]+)\])? \s* """, re.VERBOSE | re.MULTILINE) +REX_LINE = re.compile(r""" + (?P.+\.pyi?): + (?P[0-9]+):(?:[0-9]+:)?\s + (?P[a-z]+):\s + (?P.+?) + (?:\s\s\[(?P[a-z-]+)\])? + \s* +""", re.VERBOSE | re.MULTILINE) REX_LINE_NBQA = re.compile(r""" (?P.+\.ipynb:cell_[0-9]+): (?P[0-9]+):\s diff --git a/tests/test_error.py b/tests/test_error.py index ae9efd1..45b213c 100644 --- a/tests/test_error.py +++ b/tests/test_error.py @@ -46,3 +46,18 @@ def test_line3_parse(): assert e.message == 'This violates the Liskov substitution principle' assert e.category == 'note' assert e.get_clean_line(Config()) == LINE3EXP + +# --show-column-numbers files +LINE4 = 'my_project/api/views.py:10:42: note: This violates the Liskov substitution principle\r\n' # noqa +LINE4EXP = 'my_project/api/views.py:0: note: This violates the Liskov substitution principle' # noqa + + +def test_line4_parse(): + e = Error.new(LINE4) + assert e is not None + assert e.path.parts == ('my_project', 'api', 'views.py') + assert e.line_number == 10 + assert e.severity == 'note' + assert e.message == 'This violates the Liskov substitution principle' + assert e.category == 'note' + assert e.get_clean_line(Config()) == LINE4EXP