summaryrefslogtreecommitdiff
path: root/pylint/checkers
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2015-11-21 19:42:08 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2015-11-21 19:42:08 +0200
commite648e23980d361c8504d41d6b94f9659199ce060 (patch)
tree128e27f0d35d60ed78c3f291ec30abf4a67f982e /pylint/checkers
parent770dd9e70b7235e6268fb4581f1db23ab18c6cd7 (diff)
downloadpylint-e648e23980d361c8504d41d6b94f9659199ce060.tar.gz
Cleanup pylint issues
This changeset also brings a couple of changes: * rrheaders and rcheaders are dropped from html_writer.Table's constructor. They weren't used at all and it was dead code. This simplified some if statements. * _is_attribute_property is used to look for a property assignment instead on relying on a different implementation.
Diffstat (limited to 'pylint/checkers')
-rw-r--r--pylint/checkers/base.py2
-rw-r--r--pylint/checkers/classes.py15
-rw-r--r--pylint/checkers/design_analysis.py18
-rw-r--r--pylint/checkers/newstyle.py1
-rw-r--r--pylint/checkers/typecheck.py3
-rw-r--r--pylint/checkers/variables.py2
6 files changed, 18 insertions, 23 deletions
diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py
index 001a70c..cc7c786 100644
--- a/pylint/checkers/base.py
+++ b/pylint/checkers/base.py
@@ -1678,7 +1678,7 @@ class ElifChecker(BaseTokenChecker):
@staticmethod
def _is_bool_const(node):
return (isinstance(node.value, astroid.Const)
- and isinstance(node.value.value, bool))
+ and isinstance(node.value.value, bool))
def _is_actual_elif(self, node):
"""Check if the given node is an actual elif
diff --git a/pylint/checkers/classes.py b/pylint/checkers/classes.py
index 2dc45e1..6763f74 100644
--- a/pylint/checkers/classes.py
+++ b/pylint/checkers/classes.py
@@ -723,16 +723,13 @@ a metaclass class method.'}
# b = property(lambda: self._b)
stmt = node.parent.statement()
- try:
- if (isinstance(stmt, astroid.Assign) and
- (stmt in klass.body or klass.parent_of(stmt)) and
- isinstance(stmt.value, astroid.Call) and
- isinstance(stmt.value.func, astroid.Name) and
- stmt.value.func.name == 'property' and
- is_builtin_object(next(stmt.value.func.infer(), None))):
+ if (isinstance(stmt, astroid.Assign)
+ and len(stmt.targets) == 1
+ and isinstance(stmt.targets[0], astroid.AssignName)):
+ name = stmt.targets[0].name
+ if _is_attribute_property(name, klass):
return
- except astroid.InferenceError:
- pass
+
self.add_message('protected-access', node=node, args=attrname)
def visit_name(self, node):
diff --git a/pylint/checkers/design_analysis.py b/pylint/checkers/design_analysis.py
index fc10e3f..500b158 100644
--- a/pylint/checkers/design_analysis.py
+++ b/pylint/checkers/design_analysis.py
@@ -154,13 +154,13 @@ class MisdesignChecker(BaseChecker):
'help' : 'Maximum number of public methods for a class \
(see R0904).'}
),
- ('max-bool-expr',
- {'default': 5,
- 'type': 'int',
- 'metavar': '<num>',
- 'help': 'Maximum number of boolean expressions in a if '
- 'statement'}
- ),
+ ('max-bool-expr',
+ {'default': 5,
+ 'type': 'int',
+ 'metavar': '<num>',
+ 'help': 'Maximum number of boolean expressions in a if '
+ 'statement'}
+ ),
)
def __init__(self, linter=None):
@@ -322,8 +322,8 @@ class MisdesignChecker(BaseChecker):
return
nb_bool_expr = _count_boolean_expressions(condition)
if nb_bool_expr > self.config.max_bool_expr:
- self.add_message('too-many-boolean-expressions', node=condition,
- args=(nb_bool_expr, self.config.max_bool_expr))
+ self.add_message('too-many-boolean-expressions', node=condition,
+ args=(nb_bool_expr, self.config.max_bool_expr))
def visit_while(self, node):
"""increments the branches counter"""
diff --git a/pylint/checkers/newstyle.py b/pylint/checkers/newstyle.py
index 30bc6a6..489c22f 100644
--- a/pylint/checkers/newstyle.py
+++ b/pylint/checkers/newstyle.py
@@ -24,7 +24,6 @@ from pylint.checkers import BaseChecker
from pylint.checkers.utils import (
check_messages,
node_frame_class,
- safe_infer,
has_known_bases
)
diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py
index da9daf7..e5f60d6 100644
--- a/pylint/checkers/typecheck.py
+++ b/pylint/checkers/typecheck.py
@@ -27,7 +27,6 @@ import astroid.context
import astroid.arguments
from astroid import exceptions
from astroid import objects
-from astroid import node_classes
from astroid import bases
import six
@@ -56,7 +55,7 @@ def _unflatten(iterable):
if (isinstance(elem, collections.Sequence) and
not isinstance(elem, six.string_types)):
for elem in _unflatten(elem):
- yield elem
+ yield elem
elif elem and not index:
# We're interested only in the first element.
yield elem
diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py
index af87776..f0f0fa0 100644
--- a/pylint/checkers/variables.py
+++ b/pylint/checkers/variables.py
@@ -32,7 +32,7 @@ from pylint.checkers.utils import (
assign_parent, check_messages, is_inside_except, clobber_in_except,
get_all_elements, has_known_bases, node_ignores_exception,
is_inside_abstract_class, is_comprehension, is_iterable,
- safe_infer, has_known_bases)
+ safe_infer)
import six
SPECIAL_OBJ = re.compile("^_{2}[a-z]+_{2}$")