Skip to content

Commit a4d0ed4

Browse files
authored
Merge pull request #20 from drice/drice/support-show-column-numbers
feat: Add support for --show-column-numbers output
2 parents b9c86ad + 65737bf commit a4d0ed4

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

mypy_baseline/_error.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
(?:\s\s\[(?P<category>[a-z-]+)\])?
2121
\s*
2222
""", re.VERBOSE | re.MULTILINE)
23+
REX_LINE = re.compile(r"""
24+
(?P<path>.+\.pyi?):
25+
(?P<lineno>[0-9]+):(?:[0-9]+:)?\s
26+
(?P<severity>[a-z]+):\s
27+
(?P<message>.+?)
28+
(?:\s\s\[(?P<category>[a-z-]+)\])?
29+
\s*
30+
""", re.VERBOSE | re.MULTILINE)
2331
REX_LINE_NBQA = re.compile(r"""
2432
(?P<path>.+\.ipynb:cell_[0-9]+):
2533
(?P<lineno>[0-9]+):\s

tests/test_error.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,18 @@ def test_line3_parse():
4646
assert e.message == 'This violates the Liskov substitution principle'
4747
assert e.category == 'note'
4848
assert e.get_clean_line(Config()) == LINE3EXP
49+
50+
# --show-column-numbers files
51+
LINE4 = 'my_project/api/views.py:10:42: note: This violates the Liskov substitution principle\r\n' # noqa
52+
LINE4EXP = 'my_project/api/views.py:0: note: This violates the Liskov substitution principle' # noqa
53+
54+
55+
def test_line4_parse():
56+
e = Error.new(LINE4)
57+
assert e is not None
58+
assert e.path.parts == ('my_project', 'api', 'views.py')
59+
assert e.line_number == 10
60+
assert e.severity == 'note'
61+
assert e.message == 'This violates the Liskov substitution principle'
62+
assert e.category == 'note'
63+
assert e.get_clean_line(Config()) == LINE4EXP

0 commit comments

Comments
 (0)