summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2019-05-22 08:56:46 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2019-05-22 09:26:18 +0200
commit6b0003da63d30d0f345f24380c340b064713597f (patch)
tree47fce11a3b686129d09e08df4f2deb6fc762a5e6
parentf9e99fd5f3acaf2d836c7a3456f7538611cd4167 (diff)
downloadpylint-git-6b0003da63d30d0f345f24380c340b064713597f.tar.gz
Fix a bunch of linting errors from the codebase
-rw-r--r--pylint/__pkginfo__.py2
-rw-r--r--pylint/checkers/classes.py6
-rw-r--r--pylint/checkers/exceptions.py1
-rw-r--r--pylint/checkers/format.py8
-rw-r--r--pylint/checkers/misc.py4
-rw-r--r--pylint/checkers/similar.py20
-rw-r--r--pylint/checkers/spelling.py6
-rw-r--r--pylint/checkers/strings.py54
-rw-r--r--pylint/checkers/typecheck.py11
-rw-r--r--pylint/checkers/utils.py11
-rw-r--r--pylint/checkers/variables.py8
-rw-r--r--pylint/config.py10
-rw-r--r--pylint/extensions/mccabe.py12
-rw-r--r--pylint/lint.py9
-rw-r--r--pylint/message/message_handler_mix_in.py4
-rw-r--r--pylint/pyreverse/inspector.py4
-rw-r--r--pylint/pyreverse/main.py5
-rw-r--r--pylint/pyreverse/utils.py5
-rw-r--r--pylint/reporters/json_reporter.py2
-rw-r--r--pylint/reporters/ureports/text_writer.py2
-rw-r--r--pylint/utils/ast_walker.py9
-rw-r--r--pylint/utils/file_state.py8
-rw-r--r--pylint/utils/utils.py4
-rw-r--r--pylintrc3
24 files changed, 77 insertions, 131 deletions
diff --git a/pylint/__pkginfo__.py b/pylint/__pkginfo__.py
index 82caac1a4..994162d05 100644
--- a/pylint/__pkginfo__.py
+++ b/pylint/__pkginfo__.py
@@ -16,7 +16,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/master/COPYING
-# pylint: disable=W0622,C0103
+# pylint: disable=redefined-builtin,invalid-name
"""pylint packaging information"""
from __future__ import absolute_import
diff --git a/pylint/checkers/classes.py b/pylint/checkers/classes.py
index 1313f4830..a62521aba 100644
--- a/pylint/checkers/classes.py
+++ b/pylint/checkers/classes.py
@@ -929,7 +929,7 @@ a metaclass class method.",
# check if the method is hidden by an attribute
try:
- overridden = klass.instance_attr(node.name)[0] # XXX
+ overridden = klass.instance_attr(node.name)[0]
overridden_frame = overridden.frame()
if (
isinstance(overridden_frame, astroid.FunctionDef)
@@ -1268,8 +1268,7 @@ a metaclass class method.",
klass = node_frame_class(node)
- # XXX infer to be more safe and less dirty ??
- # in classes, check we are not getting a parent method
+ # In classes, check we are not getting a parent method
# through the class object or through super
callee = node.expr.as_string()
@@ -1331,7 +1330,6 @@ a metaclass class method.",
def _check_accessed_members(self, node, accessed):
"""check that accessed members are defined"""
- # XXX refactor, probably much simpler now that E0201 is in type checker
excs = ("AttributeError", "Exception", "BaseException")
for attr, nodes in accessed.items():
try:
diff --git a/pylint/checkers/exceptions.py b/pylint/checkers/exceptions.py
index 0b6827827..a89c5f5c7 100644
--- a/pylint/checkers/exceptions.py
+++ b/pylint/checkers/exceptions.py
@@ -254,7 +254,6 @@ class ExceptionRaiseLeafVisitor(BaseVisitor):
isinstance(inferred, astroid.Instance)
and inferred.__class__.__name__ != "Instance"
):
- # TODO: explain why
self.visit_default(tuple_node)
else:
self.visit(inferred)
diff --git a/pylint/checkers/format.py b/pylint/checkers/format.py
index bc935ddd0..691bfe6f9 100644
--- a/pylint/checkers/format.py
+++ b/pylint/checkers/format.py
@@ -273,8 +273,8 @@ def _get_indent_length(line):
def _get_indent_hint_line(bar_positions, bad_position):
"""Return a line with |s for each of the positions in the given lists."""
if not bar_positions:
- return ("", "")
- # TODO tabs should not be replaced by some random (8) number of spaces
+ return "", ""
+
bar_positions = [_get_indent_length(indent) for indent in bar_positions]
bad_position = _get_indent_length(bad_position)
delta_message = ""
@@ -294,7 +294,7 @@ def _get_indent_hint_line(bar_positions, bad_position):
line = [" "] * (markers[-1][0] + 1)
for position, marker in markers:
line[position] = marker
- return ("".join(line), delta_message)
+ return "".join(line), delta_message
class _ContinuedIndent:
@@ -1168,7 +1168,7 @@ class FormatChecker(BaseTokenChecker):
if not node.is_statement:
return
if not node.root().pure_python:
- return # XXX block visit of child nodes
+ return
prev_sibl = node.previous_sibling()
if prev_sibl is not None:
prev_line = prev_sibl.fromlineno
diff --git a/pylint/checkers/misc.py b/pylint/checkers/misc.py
index d4da9f33b..12dc90815 100644
--- a/pylint/checkers/misc.py
+++ b/pylint/checkers/misc.py
@@ -18,8 +18,6 @@
"""Check source code is ascii only or has an encoding declaration (PEP 263)"""
-# pylint: disable=W0511
-
import re
import tokenize
@@ -118,7 +116,7 @@ class EncodingChecker(BaseChecker):
self.add_message(
"invalid-encoded-data", line=lineno, args=(file_encoding, ex.args[2])
)
- except LookupError as ex:
+ except LookupError:
if line.startswith("#") and "coding" in line and file_encoding in line:
self.add_message(
"syntax-error",
diff --git a/pylint/checkers/similar.py b/pylint/checkers/similar.py
index 1ac5f6196..7d51d6e3b 100644
--- a/pylint/checkers/similar.py
+++ b/pylint/checkers/similar.py
@@ -13,7 +13,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/master/COPYING
-# pylint: disable=W0622
+# pylint: disable=redefined-builtin
"""a similarities / code duplication command line tool and pylint checker
"""
@@ -97,11 +97,12 @@ class Similar:
print()
print(num, "similar lines in", len(couples), "files")
couples = sorted(couples)
+ lineset = idx = None
for lineset, idx in couples:
print("==%s:%s" % (lineset.name, idx))
- # pylint: disable=W0631
- for line in lineset._real_lines[idx : idx + num]:
- print(" ", line.rstrip())
+ if lineset:
+ for line in lineset._real_lines[idx : idx + num]:
+ print(" ", line.rstrip())
nb_lignes_dupliquees += num * (len(couples) - 1)
nb_total_lignes = sum([len(lineset) for lineset in self.linesets])
print(
@@ -192,8 +193,6 @@ def stripped_lines(lines, ignore_comments, ignore_docstrings, ignore_imports):
if current_line_is_import:
line = ""
if ignore_comments:
- # XXX should use regex in checkers/format to avoid cutting
- # at a "#" in a string
line = line.split("#", 1)[0].strip()
strippedlines.append(line)
return strippedlines
@@ -380,12 +379,15 @@ class SimilarChecker(BaseChecker, Similar):
stats = self.stats
for num, couples in self._compute_sims():
msg = []
+ lineset = idx = None
for lineset, idx in couples:
msg.append("==%s:%s" % (lineset.name, idx))
msg.sort()
- # pylint: disable=W0631
- for line in lineset._real_lines[idx : idx + num]:
- msg.append(line.rstrip())
+
+ if lineset:
+ for line in lineset._real_lines[idx : idx + num]:
+ msg.append(line.rstrip())
+
self.add_message("R0801", args=(len(couples), "\n".join(msg)))
duplicated += num * (len(couples) - 1)
stats["nb_duplicated_lines"] = duplicated
diff --git a/pylint/checkers/spelling.py b/pylint/checkers/spelling.py
index f04c0a6c5..2674078b9 100644
--- a/pylint/checkers/spelling.py
+++ b/pylint/checkers/spelling.py
@@ -334,10 +334,10 @@ class SpellingChecker(BaseTokenChecker):
del suggestions[self.config.max_spelling_suggestions :]
line_segment = line[word_start_at:]
- m = re.search(r"(\W|^)(%s)(\W|$)" % word, line_segment)
- if m:
+ match = re.search(r"(\W|^)(%s)(\W|$)" % word, line_segment)
+ if match:
# Start position of second group in regex.
- col = m.regs[2][0]
+ col = match.regs[2][0]
else:
col = line_segment.index(word)
diff --git a/pylint/checkers/strings.py b/pylint/checkers/strings.py
index fd92689f6..ac7b1b73f 100644
--- a/pylint/checkers/strings.py
+++ b/pylint/checkers/strings.py
@@ -227,10 +227,12 @@ class StringFormatChecker(BaseChecker):
required_keys, required_num_args, required_key_types, required_arg_types = utils.parse_format_string(
format_string
)
- except utils.UnsupportedFormatCharacter as e:
- c = format_string[e.index]
+ except utils.UnsupportedFormatCharacter as exc:
+ formatted = format_string[exc.index]
self.add_message(
- "bad-format-character", node=node, args=(c, ord(c), e.index)
+ "bad-format-character",
+ node=node,
+ args=(formatted, ord(formatted), exc.index),
)
return
except utils.IncompleteFormatString:
@@ -368,13 +370,11 @@ class StringFormatChecker(BaseChecker):
)
def _check_new_format(self, node, func):
- """ Check the new string formatting. """
- # TODO: skip (for now) format nodes which don't have
- # an explicit string on the left side of the format operation.
- # We do this because our inference engine can't properly handle
- # redefinitions of the original string.
- # For more details, see issue 287.
- #
+ """Check the new string formatting. """
+ # Skip ormat nodes which don't have an explicit string on the
+ # left side of the format operation.
+ # We do this because our inference engine can't properly handle
+ # redefinitions of the original string.
# Note that there may not be any left side at all, if the format method
# has been assigned to another variable. See issue 351. For example:
#
@@ -593,9 +593,6 @@ class StringConstantChecker(BaseTokenChecker):
# Unicode or byte strings.
ESCAPE_CHARACTERS = "abfnrtvx\n\r\t\\'\"01234567"
- # TODO(mbp): Octal characters are quite an edge case today; people may
- # prefer a separate warning where they occur. \0 should be allowed.
-
# Characters that have a special meaning after a backslash but only in
# Unicode strings.
UNICODE_ESCAPE_CHARACTERS = "uUN"
@@ -673,14 +670,14 @@ class StringConstantChecker(BaseTokenChecker):
def process_string_token(self, token, start_row):
quote_char = None
index = None
- for index, c in enumerate(token):
- if c in "'\"":
- quote_char = c
+ for index, char in enumerate(token):
+ if char in "'\"":
+ quote_char = char
break
if quote_char is None:
return
- prefix = token[:index].lower() # markers like u, b, r.
+ prefix = token[:index].lower() # markers like u, b, r.
after_prefix = token[index:]
if after_prefix[:3] == after_prefix[-3:] == 3 * quote_char:
string_body = after_prefix[3:-3]
@@ -706,20 +703,15 @@ class StringConstantChecker(BaseTokenChecker):
# end-of-line, or one of the letters that introduce a special escape
# sequence <http://docs.python.org/reference/lexical_analysis.html>
#
- # TODO(mbp): Maybe give a separate warning about the rarely-used
- # \a \b \v \f?
- #
- # TODO(mbp): We could give the column of the problem character, but
- # add_message doesn't seem to have a way to pass it through at present.
- i = 0
+ index = 0
while True:
- i = string_body.find("\\", i)
- if i == -1:
+ index = string_body.find("\\", index)
+ if index == -1:
break
# There must be a next character; having a backslash at the end
# of the string would be a SyntaxError.
- next_char = string_body[i + 1]
- match = string_body[i : i + 2]
+ next_char = string_body[index + 1]
+ match = string_body[index : index + 2]
if next_char in self.UNICODE_ESCAPE_CHARACTERS:
if "u" in prefix:
pass
@@ -730,15 +722,19 @@ class StringConstantChecker(BaseTokenChecker):
"anomalous-unicode-escape-in-string",
line=start_row,
args=(match,),
+ col_offset=index,
)
elif next_char not in self.ESCAPE_CHARACTERS:
self.add_message(
- "anomalous-backslash-in-string", line=start_row, args=(match,)
+ "anomalous-backslash-in-string",
+ line=start_row,
+ args=(match,),
+ col_offset=index,
)
# Whether it was a valid escape or not, backslash followed by
# another character can always be consumed whole: the second
# character can never be the start of a new backslash escape.
- i += 2
+ index += 2
def register(linter):
diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py
index 333f54ace..d32f90dcc 100644
--- a/pylint/checkers/typecheck.py
+++ b/pylint/checkers/typecheck.py
@@ -132,8 +132,6 @@ def _is_owner_ignored(owner, name, ignored_classes, ignored_modules):
@singledispatch
def _node_names(node):
- # TODO: maybe we need an ABC for checking if an object is a scoped node
- # or not?
if not hasattr(node, "locals"):
return []
return node.locals.keys()
@@ -451,7 +449,6 @@ def _determine_callable(callable_obj):
# and Function inherits Lambda.
parameters = 0
if hasattr(callable_obj, "implicit_parameters"):
- # TODO: replace with a Callable check
parameters = callable_obj.implicit_parameters()
if isinstance(callable_obj, astroid.BoundMethod):
# Bound methods have an extra implicit 'self' argument.
@@ -881,7 +878,6 @@ accessed. Python regular expressions are accepted.",
missingattr.add((owner, name))
continue
except AttributeError:
- # XXX method / function
continue
except exceptions.NotFoundError:
# This can't be moved before the actual .getattr call,
@@ -995,9 +991,6 @@ accessed. Python regular expressions are accepted.",
# there. If that attribute is a property or a subclass of properties,
# then most likely it's not callable.
- # TODO: since astroid doesn't understand descriptors very well
- # we will not handle them here, right now.
-
expr = node.func.expr
klass = safe_infer(expr)
if (
@@ -1179,7 +1172,7 @@ accessed. Python regular expressions are accepted.",
else:
parameters[i][1] = True
elif keyword in kwparams:
- if kwparams[keyword][1]: # XXX is that even possible?
+ if kwparams[keyword][1]:
# Duplicate definition of function parameter.
self.add_message(
"redundant-keyword-arg",
@@ -1216,7 +1209,6 @@ accessed. Python regular expressions are accepted.",
display_name = "<tuple>"
else:
display_name = repr(name)
- # TODO(cpopa): this should be removed after PyCQA/astroid/issues/177
if not has_no_context_positional_variadic:
self.add_message(
"no-value-for-parameter",
@@ -1631,7 +1623,6 @@ class IterableChecker(BaseChecker):
@check_messages("not-an-iterable")
def visit_yieldfrom(self, node):
- # TODO: hack which can be removed once we support decorators inference
if self._is_asyncio_coroutine(node.value):
return
self._check_iterable(node.value)
diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py
index 9c4e71864..3d860fc47 100644
--- a/pylint/checkers/utils.py
+++ b/pylint/checkers/utils.py
@@ -231,15 +231,14 @@ def get_all_elements(
"""Recursively returns all atoms in nested lists and tuples."""
if isinstance(node, (astroid.Tuple, astroid.List)):
for child in node.elts:
- for e in get_all_elements(child):
- yield e
+ yield from get_all_elements(child)
else:
yield node
def clobber_in_except(
node: astroid.node_classes.NodeNG
-) -> Tuple[bool, Tuple[str, str]]:
+) -> Tuple[bool, Optional[Tuple[str, str]]]:
"""Checks if an assignment node in an except handler clobbers an existing
variable.
@@ -251,7 +250,7 @@ def clobber_in_except(
if isinstance(node, astroid.AssignName):
name = node.name
if is_builtin(name):
- return (True, (name, "builtins"))
+ return True, (name, "builtins")
stmts = node.lookup(name)[1]
if stmts and not isinstance(
@@ -1027,8 +1026,6 @@ def _supports_protocol(
if protocol_callback(value):
return True
- # TODO: this is not needed in astroid 2.0, where we can
- # check the type using a virtual base class instead.
if (
isinstance(value, _bases.Proxy)
and isinstance(value._proxied, astroid.BaseInstance)
@@ -1072,7 +1069,6 @@ def supports_delitem(value: astroid.node_classes.NodeNG) -> bool:
return _supports_protocol(value, _supports_delitem_protocol)
-# TODO(cpopa): deprecate these or leave them as aliases?
@lru_cache(maxsize=1024)
def safe_infer(
node: astroid.node_classes.NodeNG, context=None
@@ -1104,7 +1100,6 @@ def has_known_bases(klass: astroid.ClassDef, context=None) -> bool:
pass
for base in klass.bases:
result = safe_infer(base, context=context)
- # TODO: check for A->B->A->B pattern in class structure too?
if (
not isinstance(result, astroid.ClassDef)
or result is klass
diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py
index a64b3ceab..c91880c24 100644
--- a/pylint/checkers/variables.py
+++ b/pylint/checkers/variables.py
@@ -214,11 +214,11 @@ def _detect_global_scope(node, frame, defframe):
return False
break_scopes = []
- for s in (scope, def_scope):
+ for current_scope in (scope, def_scope):
# Look for parent scopes. If there is anything different
# than a module or a class scope, then they frames don't
# share a global scope.
- parent_scope = s
+ parent_scope = current_scope
while parent_scope:
if not isinstance(parent_scope, (astroid.ClassDef, astroid.Module)):
break_scopes.append(parent_scope)
@@ -252,7 +252,6 @@ def _fix_dot_imports(not_consumed):
like 'xml' (when we have both 'xml.etree' and 'xml.sax'), to 'xml.etree'
and 'xml.sax' respectively.
"""
- # TODO: this should be improved in issue astroid #46
names = {}
for name, stmts in not_consumed.items():
if any(
@@ -984,7 +983,6 @@ class VariablesChecker(BaseChecker):
return
# Ignore names imported by the global statement.
- # FIXME: should only ignore them if it's assigned latter
if isinstance(stmt, (astroid.Global, astroid.Import, astroid.ImportFrom)):
# Detect imports, assigned to global statements.
if global_names and _import_name_is_global(stmt, global_names):
@@ -1855,8 +1853,6 @@ class VariablesChecker(BaseChecker):
except astroid.InferenceError:
return None
if module_names:
- # FIXME: other message if name is not the latest part of
- # module_names ?
modname = module.name if module else "__dict__"
self.add_message(
"no-name-in-module", node=node, args=(".".join(module_names), modname)
diff --git a/pylint/config.py b/pylint/config.py
index 8b0373f61..9ccc1f28c 100644
--- a/pylint/config.py
+++ b/pylint/config.py
@@ -49,14 +49,6 @@ import time
from pylint import utils
-# TODO(cpopa): this module contains the logic for the
-# configuration parser and for the command line parser,
-# but it's really coupled to optparse's internals.
-# The code was copied almost verbatim from logilab.common,
-# in order to not depend on it anymore and it will definitely
-# need a cleanup. It could be completely reengineered as well.
-
-
USER_HOME = os.path.expanduser("~")
if "PYLINTHOME" in os.environ:
PYLINT_HOME = os.environ["PYLINTHOME"]
@@ -245,7 +237,6 @@ def _validate(value, optdict, name=""):
try:
_type = optdict["type"]
except KeyError:
- # FIXME
return value
return _call_validator(_type, optdict, name, value)
@@ -751,7 +742,6 @@ class OptionsManagerMixIn:
try:
self.global_set_option(option, value)
except (KeyError, optparse.OptionError):
- # TODO handle here undeclared options appearing in the config file
continue
def load_configuration(self, **kwargs):
diff --git a/pylint/extensions/mccabe.py b/pylint/extensions/mccabe.py
index 69bc1775b..fa9cfd1b0 100644
--- a/pylint/extensions/mccabe.py
+++ b/pylint/extensions/mccabe.py
@@ -37,8 +37,8 @@ class PathGraphingAstVisitor(Mccabe_PathGraphingAstVisitor):
klass = node.__class__
meth = self._cache.get(klass)
if meth is None:
- className = klass.__name__
- meth = getattr(self.visitor, "visit" + className, self.default)
+ class_name = klass.__name__
+ meth = getattr(self.visitor, "visit" + class_name, self.default)
self._cache[klass] = meth
return meth(node, *args)
@@ -116,9 +116,7 @@ class PathGraphingAstVisitor(Mccabe_PathGraphingAstVisitor):
self._append_node(node)
self._subgraph_parse(node, node, extra_blocks)
- def _subgraph_parse(
- self, node, pathnode, extra_blocks
- ): # pylint: disable=unused-argument
+ def _subgraph_parse(self, node, pathnode, extra_blocks):
"""parse the body and any `else` block of `if` and `for` statements"""
loose_ends = []
self.tail = node
@@ -137,8 +135,8 @@ class PathGraphingAstVisitor(Mccabe_PathGraphingAstVisitor):
if node:
bottom = "%s" % self._bottom_counter
self._bottom_counter += 1
- for le in loose_ends:
- self.graph.connect(le, bottom)
+ for end in loose_ends:
+ self.graph.connect(end, bottom)
self.tail = bottom
diff --git a/pylint/lint.py b/pylint/lint.py
index 1718b03a5..f59919649 100644
--- a/pylint/lint.py
+++ b/pylint/lint.py
@@ -101,7 +101,6 @@ def _ast_from_string(data, filepath, modname):
def _read_stdin():
# https://mail.python.org/pipermail/python-list/2012-November/634424.html
- # FIXME should this try to check the file's declared encoding?
sys.stdin = TextIOWrapper(sys.stdin.detach(), encoding="utf-8")
return sys.stdin.read()
@@ -765,7 +764,6 @@ class PyLinter(
checker.load_defaults()
# Register the checker, but disable all of its messages.
- # TODO(cpopa): we should have a better API for this.
if not getattr(checker, "enabled", True):
self.disable(checker.name)
@@ -1136,9 +1134,7 @@ class PyLinter(
ast_node = self.get_ast(filepath, modname)
if ast_node is None:
continue
- # XXX to be correct we need to keep module_msgs_state for every
- # analyzed module (the problem stands with localized messages which
- # are only detected in the .close step)
+
self.file_state = FileState(descr["basename"])
self._ignore_file = False
# fix the current file (if the source file was not available or
@@ -1253,7 +1249,6 @@ class PyLinter(
if self.file_state.base_name is not None:
# load previous results if any
previous_stats = config.load_results(self.file_state.base_name)
- # XXX code below needs refactoring to be more reporter agnostic
self.reporter.on_close(self.stats, previous_stats)
if self.config.reports:
sect = self.make_reports(self.stats, previous_stats)
@@ -1746,7 +1741,7 @@ group are mutually exclusive.",
self.linter.print_full_documentation()
sys.exit(0)
- def cb_list_messages(self, option, optname, value, parser): # FIXME
+ def cb_list_messages(self, option, optname, value, parser):
"""optik callback for printing available messages"""
self.linter.msgs_store.list_messages()
sys.exit(0)
diff --git a/pylint/message/message_handler_mix_in.py b/pylint/message/message_handler_mix_in.py
index 79746f727..53eb86870 100644
--- a/pylint/message/message_handler_mix_in.py
+++ b/pylint/message/message_handler_mix_in.py
@@ -300,9 +300,7 @@ class MessagesHandlerMixIn:
if line is None and node is not None:
line = node.fromlineno
if col_offset is None and hasattr(node, "col_offset"):
- col_offset = (
- node.col_offset
- ) # XXX measured in bytes for utf-8, divide by two for chars?
+ col_offset = node.col_offset
# should this message be displayed
if not self.is_message_enabled(msgid, line, confidence):
diff --git a/pylint/pyreverse/inspector.py b/pylint/pyreverse/inspector.py
index b4df388be..92418be68 100644
--- a/pylint/pyreverse/inspector.py
+++ b/pylint/pyreverse/inspector.py
@@ -40,7 +40,6 @@ def _astroid_wrapper(func, modname):
def interfaces(node, herited=True, handler_func=_iface_hdlr):
"""Return an iterator on interfaces implemented by the given class node."""
- # FIXME: what if __implements__ = (MyIFace, MyParent.__implements__)...
try:
implements = bases.Instance(node).getattr("__implements__")[0]
except exceptions.NotFoundError:
@@ -265,8 +264,6 @@ class Linker(IdGeneratorMixIn, utils.LocalsVisitor):
fullname = "%s.%s" % (basename, name[0])
if fullname.find(".") > -1:
try:
- # TODO: don't use get_module_part,
- # missing package precedence
fullname = modutils.get_module_part(fullname, context_file)
except ImportError:
continue
@@ -346,7 +343,6 @@ def project_from_files(
ast = func_wrapper(astroid_manager.ast_from_file, fpath)
if ast is None:
continue
- # XXX why is first file defining the project.path ?
project.path = project.path or ast.file
project.add_module(ast)
base_name = ast.name
diff --git a/pylint/pyreverse/main.py b/pylint/pyreverse/main.py
index 8d30eacba..98d5ec437 100644
--- a/pylint/pyreverse/main.py
+++ b/pylint/pyreverse/main.py
@@ -113,11 +113,6 @@ OPTIONS = (
help="include module name in representation of classes",
),
),
- # TODO : generate dependencies like in pylint
- # ("package-dependencies",
- # dict(short="M", action="store", metavar='<package_depth>', type='int',
- # help='show <package_depth> module dependencies beyond modules in \
- # <projects> (for the package diagram)')),
(
"only-classnames",
dict(
diff --git a/pylint/pyreverse/utils.py b/pylint/pyreverse/utils.py
index b60f336ab..8c5243202 100644
--- a/pylint/pyreverse/utils.py
+++ b/pylint/pyreverse/utils.py
@@ -203,13 +203,14 @@ class LocalsVisitor(ASTWalker):
def __init__(self):
ASTWalker.__init__(self, self)
- self._visited = {}
+ self._visited = set()
def visit(self, node):
"""launch the visit starting from the given node"""
if node in self._visited:
return None
- self._visited[node] = 1 # FIXME: use set ?
+
+ self._visited.add(node)
methods = self.get_callbacks(node)
if methods[0] is not None:
methods[0](node)
diff --git a/pylint/reporters/json_reporter.py b/pylint/reporters/json_reporter.py
index efac6f5c3..c5523ba95 100644
--- a/pylint/reporters/json_reporter.py
+++ b/pylint/reporters/json_reporter.py
@@ -48,7 +48,7 @@ class JSONReporter(BaseReporter):
"""Launch layouts display"""
print(json.dumps(self.messages, indent=4), file=self.out)
- def display_reports(self, layout): # pylint: disable=arguments-differ
+ def display_reports(self, layout):
"""Don't do nothing in this reporter."""
def _display(self, layout):
diff --git a/pylint/reporters/ureports/text_writer.py b/pylint/reporters/ureports/text_writer.py
index acb6a9ac8..5f05ccbd4 100644
--- a/pylint/reporters/ureports/text_writer.py
+++ b/pylint/reporters/ureports/text_writer.py
@@ -71,7 +71,7 @@ class TextWriter(BaseWriter):
format_strings = format_strings.split(" ")
table_linesep = "\n+" + "+".join(["-" * w for w in cols_width]) + "+\n"
headsep = "\n+" + "+".join(["=" * w for w in cols_width]) + "+\n"
- # FIXME: layout.cheaders
+
self.write(table_linesep)
for index, line in enumerate(table_content):
self.write("|")
diff --git a/pylint/utils/ast_walker.py b/pylint/utils/ast_walker.py
index 1350d61f2..2e7a6da97 100644
--- a/pylint/utils/ast_walker.py
+++ b/pylint/utils/ast_walker.py
@@ -26,7 +26,6 @@ class ASTWalker:
def add_checker(self, checker):
"""walk to the checker's dir and collect visit and leave methods"""
- # XXX : should be possible to merge needed_checkers and add_checker
vcids = set()
lcids = set()
visits = self.visit_events
@@ -71,10 +70,10 @@ class ASTWalker:
if astroid.is_statement:
self.nbstatements += 1
# generate events for this node on each checker
- for cb in visit_events or ():
- cb(astroid)
+ for callback in visit_events or ():
+ callback(astroid)
# recurse on children
for child in astroid.get_children():
self.walk(child)
- for cb in leave_events or ():
- cb(astroid)
+ for callback in leave_events or ():
+ callback(astroid)
diff --git a/pylint/utils/file_state.py b/pylint/utils/file_state.py
index 468445cf3..7878d3414 100644
--- a/pylint/utils/file_state.py
+++ b/pylint/utils/file_state.py
@@ -45,10 +45,10 @@ class FileState:
#
# 1. def meth8(self):
# 2. """test late disabling"""
- # 3. # pylint: disable=E1102
- # 4. print self.blip
- # 5. # pylint: disable=E1101
- # 6. print self.bla
+ # 3. pylint: disable=not-callable
+ # 4. print(self.blip)
+ # 5. pylint: disable=no-member
+ # 6. print(self.bla)
#
# E1102 should be disabled from line 1 to 6 while E1101 from line 5 to 6
#
diff --git a/pylint/utils/utils.py b/pylint/utils/utils.py
index e78cd98a4..ab28a07b5 100644
--- a/pylint/utils/utils.py
+++ b/pylint/utils/utils.py
@@ -127,8 +127,8 @@ def expand_modules(files_or_modules, black_list, black_list_re):
if filepath is None:
continue
except (ImportError, SyntaxError) as ex:
- # FIXME p3k : the SyntaxError is a Python bug and should be
- # removed as soon as possible http://bugs.python.org/issue10588
+ # The SyntaxError is a Python bug and should be
+ # removed once we move away from imp.find_module: http://bugs.python.org/issue10588
errors.append({"key": "fatal", "mod": modname, "ex": ex})
continue
diff --git a/pylintrc b/pylintrc
index 112277e0a..3475fb767 100644
--- a/pylintrc
+++ b/pylintrc
@@ -40,7 +40,7 @@ confidence=
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time. See also the "--disable" option for examples.
-#enable=
+enable=use-symbolic-message-instead,useless-supression,fixme
# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
@@ -55,7 +55,6 @@ confidence=
disable=
attribute-defined-outside-init,
duplicate-code,
- fixme,
invalid-name,
missing-docstring,
protected-access,