diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2017-04-13 11:17:20 +0300 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2017-04-13 11:17:20 +0300 |
commit | 3ccda499db433200e783d5be76004930817efe47 (patch) | |
tree | 823530c2339375167f4cec5172a56aa18bbc7394 | |
parent | 9aeb753f066fd5594c308d28a68031898079736b (diff) | |
download | pylint-git-3ccda499db433200e783d5be76004930817efe47.tar.gz |
Minor formatting issues
-rw-r--r-- | pylint/checkers/base.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py index 34df77c1c..a0d8c4313 100644 --- a/pylint/checkers/base.py +++ b/pylint/checkers/base.py @@ -62,7 +62,7 @@ PY3K = sys.version_info >= (3, 0) PY35 = sys.version_info >= (3, 5) # Name categories that are always consistent with all naming conventions. -EXEMPT_NAME_CATEGORIES = set(('exempt', 'ignore')) +EXEMPT_NAME_CATEGORIES = {'exempt', 'ignore'} # A mapping from builtin-qname -> symbol, to be used when generating messages # about dangerous default values as arguments @@ -72,7 +72,6 @@ DEFAULT_ARGUMENT_SYMBOLS = dict( ) REVERSED_COMPS = {'<': '>', '<=': '>=', '>': '<', '>=': '<='} -del re def _redefines_import(node): """ Detect that the given node (AssName) is inside an @@ -94,6 +93,7 @@ def _redefines_import(node): return True return False + def in_loop(node): """return True if the node is inside a kind of for loop""" parent = node.parent @@ -104,6 +104,7 @@ def in_loop(node): parent = parent.parent return False + def in_nested_list(nested_list, obj): """return true if the object is an element of <nested_list> or of a nested list @@ -116,6 +117,7 @@ def in_nested_list(nested_list, obj): return True return False + def _loop_exits_early(loop): """Returns true if a loop has a break statement in its body.""" loop_nodes = (astroid.For, astroid.While) @@ -133,6 +135,7 @@ def _loop_exits_early(loop): return True return False + def _is_multi_naming_match(match, node_type, confidence): return (match is not None and match.lastgroup is not None and @@ -246,6 +249,7 @@ def report_by_type_stats(sect, stats, old_stats): nice_stats[node_type].get('percent_badname', '0')) sect.append(reporter_nodes.Table(children=lines, cols=6, rheaders=1)) + def redefined_by_decorator(node): """return True if the object is a method redefined via decorator. @@ -267,6 +271,7 @@ class _BasicChecker(checkers.BaseChecker): __implements__ = interfaces.IAstroidChecker name = 'basic' + class BasicErrorChecker(_BasicChecker): msgs = { 'E0100': ('__init__ method is a generator', @@ -604,7 +609,6 @@ class BasicErrorChecker(_BasicChecker): args=(redeftype, defined_self.fromlineno)) - class BasicChecker(_BasicChecker): """checks for : * doc strings @@ -1123,6 +1127,7 @@ _NAME_TYPES = { 'inlinevar': (COMP_VAR_RGX, 'inline iteration'), } + def _create_naming_options(): name_options = [] for name_type, (rgx, human_readable_name) in six.iteritems(_NAME_TYPES): @@ -1382,12 +1387,12 @@ class DocStringChecker(_BasicChecker): ), ) - def open(self): self.stats = self.linter.add_stats(undocumented_module=0, undocumented_function=0, undocumented_method=0, undocumented_class=0) + @utils.check_messages('missing-docstring', 'empty-docstring') def visit_module(self, node): self._check_docstring('module', node) @@ -1478,6 +1483,7 @@ class PassChecker(_BasicChecker): 'Used when a "pass" statement that can be avoided is ' 'encountered.'), } + @utils.check_messages('unnecessary-pass') def visit_pass(self, node): if len(node.parent.child_sequence(node)) > 1: @@ -1643,7 +1649,6 @@ class ComparisonChecker(_BasicChecker): self.add_message('unidiomatic-typecheck', node=node) - def register(linter): """required method to auto register this checker""" linter.register_checker(BasicErrorChecker(linter)) |