-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathsublime_python_errors.py
72 lines (49 loc) · 1.93 KB
/
sublime_python_errors.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import SublimePythonIDE.pyflakes
import SublimePythonIDE.pyflakes.messages
SublimePythonIDE.pyflakes.messages.Message.__str__ = (
lambda self: self.message % self.message_args
)
class PyflakesLoc:
""" Error location data for pyflakes.
pyflakes 0.7 wants loc as {lineno, col_offset} object
we ducktype it here. Apparently AST code
has been upgraded in some point?
Online lineno attribute is required.
"""
def __init__(self, lineno):
self.lineno = lineno
class PythonLintError(SublimePythonIDE.pyflakes.messages.Message):
def __init__(
self, filename, loc, level, message,
message_args, offset=0, text=None):
super(PythonLintError, self).__init__(filename, PyflakesLoc(loc))
self.level = level
self.message = message
self.message_args = message_args
self.offset = offset
if text is not None:
self.text = text
class Pep8Error(PythonLintError):
def __init__(self, filename, loc, offset, code, text):
# PEP 8 Errors are downgraded to "warnings"
super(Pep8Error, self).__init__(
filename, loc, 'W', '[W] PEP 8 (%s): %s',
(code, text), offset=offset, text=text
)
class Pep8Warning(PythonLintError):
def __init__(self, filename, loc, offset, code, text):
# PEP 8 Warnings are downgraded to "violations"
super(Pep8Warning, self).__init__(
filename, loc, 'V', '[V] PEP 8 (%s): %s',
(code, text), offset=offset, text=text
)
class OffsetError(PythonLintError):
def __init__(self, filename, loc, text, offset):
super(OffsetError, self).__init__(
filename, loc, 'E', '[E] %r', (text,), offset=offset + 1, text=text
)
class PythonError(PythonLintError):
def __init__(self, filename, loc, text):
super(PythonError, self).__init__(
filename, loc, 'E', '[E] %r', (text,), text=text
)