mirror of
https://fuchsia.googlesource.com/third_party/github.com/pylint-dev/pylint
synced 2024-09-20 07:30:13 +00:00
4192e79a83
Astng will try to find the right encoding and provide the right "stream" interface for the Pylint checkers. Reading a stream with the wrong encoding in py3k will generate a UnicodeError. The introduced a 'F0010' failure should maybe be replaced by E0501, E0502 and F0002? However, can we call 'unexpected errors' the ASTNGBuildingExceptions that we raise in logilab.astng.builder?
34 lines
1011 B
Python
34 lines
1011 B
Python
from pylint.interfaces import IRawChecker
|
|
from pylint.checkers import BaseChecker
|
|
|
|
class MyRawChecker(BaseChecker):
|
|
"""check for line continuations with '\' instead of using triple
|
|
quoted string or parenthesis
|
|
"""
|
|
|
|
__implements__ = IRawChecker
|
|
|
|
name = 'custom_raw'
|
|
msgs = {'W9901': ('use \\ for line continuation',
|
|
('Used when a \\ is used for a line continuation instead'
|
|
' of using triple quoted string or parenthesis.')),
|
|
}
|
|
options = ()
|
|
|
|
def process_module(self, node):
|
|
"""process a module
|
|
|
|
the module's content is accessible via node.file_stream object
|
|
"""
|
|
stream = node.file_stream
|
|
stream.seek(0)
|
|
for (lineno, line) in enumerate(stream):
|
|
if line.rstrip().endswith('\\'):
|
|
self.add_message('W9901', line=lineno)
|
|
|
|
|
|
def register(linter):
|
|
"""required method to auto register this checker"""
|
|
linter.register_checker(MyRawChecker(linter))
|
|
|