Skip to content

Commit

Permalink
Merge pull request #20 from drice/drice/support-show-column-numbers
Browse files Browse the repository at this point in the history
feat: Add support for --show-column-numbers output
  • Loading branch information
orsinium authored Dec 2, 2023
2 parents b9c86ad + 65737bf commit a4d0ed4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mypy_baseline/_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
(?:\s\s\[(?P<category>[a-z-]+)\])?
\s*
""", re.VERBOSE | re.MULTILINE)
REX_LINE = re.compile(r"""
(?P<path>.+\.pyi?):
(?P<lineno>[0-9]+):(?:[0-9]+:)?\s
(?P<severity>[a-z]+):\s
(?P<message>.+?)
(?:\s\s\[(?P<category>[a-z-]+)\])?
\s*
""", re.VERBOSE | re.MULTILINE)
REX_LINE_NBQA = re.compile(r"""
(?P<path>.+\.ipynb:cell_[0-9]+):
(?P<lineno>[0-9]+):\s
Expand Down
15 changes: 15 additions & 0 deletions tests/test_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a4d0ed4

Please sign in to comment.