Skip to content

Commit

Permalink
Capture filename and error code
Browse files Browse the repository at this point in the history
  • Loading branch information
kaste committed Mar 21, 2020
1 parent d5e91e5 commit 72f651d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ class TemporaryDirectory(Protocol):
class Mypy(PythonLinter):
"""Provides an interface to mypy."""

regex = r'^(\w:)?[^:]+:(?P<line>\d+):((?P<col>\d+):)?\s*(?P<error_type>[^:]+):\s*(?P<message>.+)'
regex = (
r'^(?P<filename>.+?):(?P<line>\d+):((?P<col>\d+):)?\s*'
r'(?P<error_type>[^:]+):\s*(?P<message>.+?)(\s\s\[(?P<code>.+)\])?$'
)
line_col_base = (1, 1)
tempfile_suffix = 'py'
default_type = const.WARNING
Expand All @@ -63,6 +66,7 @@ class Mypy(PythonLinter):
"--cache-dir:": "",
# Allow users to disable this
"--incremental": True,
"--show-error-codes": True,
# Need this to silent lints for other files. Alternatively: 'skip'
"--follow-imports:": "silent",
}
Expand Down

3 comments on commit 72f651d

@0xTowel
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks regex parsing on Windows as the drive letter is no longer accounted for.

See: #46

@kaste
Copy link
Collaborator Author

@kaste kaste commented on 72f651d May 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How so? I'm on Windows myself. https://regex101.com/r/syoQm7/1

@0xTowel
Copy link

@0xTowel 0xTowel commented on 72f651d May 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh this is my mistake. I am indeed getting errors, but they aren't from this regex change. I just misread the regex, please disregard.

Please sign in to comment.