diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/custom.py | 32 | ||||
-rw-r--r-- | examples/custom_raw.py | 22 |
2 files changed, 31 insertions, 23 deletions
diff --git a/examples/custom.py b/examples/custom.py index 039b018b8..7ee97bb5f 100644 --- a/examples/custom.py +++ b/examples/custom.py @@ -14,7 +14,7 @@ class MyAstroidChecker(BaseChecker): __implements__ = IAstroidChecker # The name defines a custom section of the config for this checker. - name = 'custom' + name = "custom" # The priority indicates the order that pylint will run the checkers. priority = -1 # This class variable declares the messages (ie the warnings and errors) @@ -24,9 +24,7 @@ class MyAstroidChecker(BaseChecker): # a unique symbol that identifies the message, # and a detailed help message # that will be included in the documentation. - 'W0001': ('Message that will be emitted', - 'message-symbol', - 'Message help') + "W0001": ("Message that will be emitted", "message-symbol", "Message help") } # This class variable declares the options # that are configurable by the user. @@ -35,12 +33,16 @@ class MyAstroidChecker(BaseChecker): # and in config files, and a dictionary of arguments # (similar to those to those to # argparse.ArgumentParser.add_argument). - ('store-locals-indicator', - {'default': 'properties', - 'help': ('The expression name that indicates that the locals should ' - 'be stored'), - }, - ), + ( + "store-locals-indicator", + { + "default": "properties", + "help": ( + "The expression name that indicates that the locals should " + "be stored" + ), + }, + ), ) def visit_call(self, node): @@ -51,10 +53,12 @@ class MyAstroidChecker(BaseChecker): :param node: The node to check. :type node: astroid.node_classes.Call """ - if not (isinstance(node.func, astroid.Attribute) - and isinstance(node.func.expr, astroid.Name) - and node.func.expr.name == self.config.store_locals_indicator - and node.func.attrname == 'create'): + if not ( + isinstance(node.func, astroid.Attribute) + and isinstance(node.func.expr, astroid.Name) + and node.func.expr.name == self.config.store_locals_indicator + and node.func.attrname == "create" + ): return in_class = node.frame() for param in node.args: diff --git a/examples/custom_raw.py b/examples/custom_raw.py index fb28d4931..63e4aeb8e 100644 --- a/examples/custom_raw.py +++ b/examples/custom_raw.py @@ -9,12 +9,17 @@ class MyRawChecker(BaseChecker): __implements__ = IRawChecker - name = 'custom_raw' - msgs = {'W9901': ('use \\ for line continuation', - 'backslash-line-continuation', - ('Used when a \\ is used for a line continuation instead' - ' of using triple quoted string or parenthesis.')), - } + name = "custom_raw" + msgs = { + "W9901": ( + "use \\ for line continuation", + "backslash-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): @@ -24,9 +29,8 @@ class MyRawChecker(BaseChecker): """ with node.stream() as stream: for (lineno, line) in enumerate(stream): - if line.rstrip().endswith('\\'): - self.add_message('backslash-line-continuation', - line=lineno) + if line.rstrip().endswith("\\"): + self.add_message("backslash-line-continuation", line=lineno) def register(linter): |