Skip to content

Commit d8d7ae9

Browse files
committed
Fix line number type while using buggy 3rd-party linters
1 parent 8de40c1 commit d8d7ae9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

linter.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ def find_errors(self, output):
105105
"""find relevant issues and yield a LintMatch"""
106106
if data and "Issues" in data:
107107
for issue in data["Issues"]:
108+
"""fix 3rd-party linter bugs"""
109+
issue = self._formalize(issue)
110+
108111
"""detect broken canonical imports"""
109112
if ("code in directory" in issue["Text"]
110113
and "expects import" in issue["Text"]):
@@ -174,6 +177,14 @@ def _background_lint(self, cmd, code):
174177
self.notify_failure()
175178
return ""
176179

180+
def _formalize(self, issue):
181+
"""some linters return numbers as string"""
182+
if not isinstance(issue["Pos"]["Line"], int):
183+
issue["Pos"]["Line"] = int(issue["Pos"]["Line"])
184+
if not isinstance(issue["Pos"]["Column"], int):
185+
issue["Pos"]["Column"] = int(issue["Pos"]["Column"])
186+
return issue
187+
177188
def _shortname(self, issue):
178189
"""find and return short filename"""
179190
return os.path.basename(issue["Pos"]["Filename"])

0 commit comments

Comments
 (0)