diff options
| author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-04-18 23:05:36 +0200 |
|---|---|---|
| committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-04-19 23:09:13 +0200 |
| commit | 8c88b6e8babe9bed9140bc396b4721ffe668153c (patch) | |
| tree | 8daa6a1469f33dd789c254cdab630ae3b289d098 | |
| parent | 785b61e479a5aa2624cd7588b07c059131be9bf4 (diff) | |
| download | astroid-git-8c88b6e8babe9bed9140bc396b4721ffe668153c.tar.gz | |
Enable checks for and fix useless suppression
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | astroid/__init__.py | 8 | ||||
| -rw-r--r-- | astroid/brain/brain_builtin_inference.py | 2 | ||||
| -rw-r--r-- | astroid/brain/brain_namedtuple_enum.py | 2 | ||||
| -rw-r--r-- | astroid/node_classes.py | 11 | ||||
| -rw-r--r-- | astroid/protocols.py | 2 | ||||
| -rw-r--r-- | astroid/raw_building.py | 2 | ||||
| -rw-r--r-- | astroid/scoped_nodes.py | 1 | ||||
| -rw-r--r-- | astroid/util.py | 1 | ||||
| -rw-r--r-- | pylintrc | 6 | ||||
| -rw-r--r-- | tests/unittest_inference.py | 5 |
11 files changed, 13 insertions, 28 deletions
@@ -14,3 +14,4 @@ astroid.egg-info/ .eggs/ .pytest_cache/ .mypy_cache/ +venv diff --git a/astroid/__init__.py b/astroid/__init__.py index bc9c5229..42a05539 100644 --- a/astroid/__init__.py +++ b/astroid/__init__.py @@ -45,6 +45,7 @@ import sys import wrapt +from .__pkginfo__ import version as __version__ _Context = enum.Enum("Context", "Load Store Del") Load = _Context.Load @@ -52,13 +53,8 @@ Store = _Context.Store Del = _Context.Del del _Context - -# pylint: disable=wrong-import-order,wrong-import-position -from .__pkginfo__ import version as __version__ - # WARNING: internal imports order matters ! - -# pylint: disable=redefined-builtin +# pylint: disable=wrong-import-order,wrong-import-position,redefined-builtin # make all exception classes accessible from astroid package from astroid.exceptions import * diff --git a/astroid/brain/brain_builtin_inference.py b/astroid/brain/brain_builtin_inference.py index 4e3d6e75..96bf9025 100644 --- a/astroid/brain/brain_builtin_inference.py +++ b/astroid/brain/brain_builtin_inference.py @@ -152,7 +152,7 @@ _extend_builtins( def _builtin_filter_predicate(node, builtin_name): - if ( # pylint: disable=too-many-boolean-expressions + if ( builtin_name == "type" and node.root().name == "re" and isinstance(node.func, nodes.Name) diff --git a/astroid/brain/brain_namedtuple_enum.py b/astroid/brain/brain_namedtuple_enum.py index c49afa74..ba59e1e0 100644 --- a/astroid/brain/brain_namedtuple_enum.py +++ b/astroid/brain/brain_namedtuple_enum.py @@ -233,7 +233,7 @@ def _get_renamed_namedtuple_attributes(field_names): names = list(field_names) seen = set() for i, name in enumerate(field_names): - if ( # pylint: disable=too-many-boolean-expressions + if ( not all(c.isalnum() or c == "_" for c in name) or keyword.iskeyword(name) or not name diff --git a/astroid/node_classes.py b/astroid/node_classes.py index 8d547e53..77625104 100644 --- a/astroid/node_classes.py +++ b/astroid/node_classes.py @@ -29,10 +29,7 @@ # Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html # For details: https://github.com/PyCQA/astroid/blob/master/LICENSE -# pylint: disable=too-many-lines; https://github.com/PyCQA/astroid/issues/465 - -"""Module for some node classes. More nodes in scoped_nodes.py -""" +"""Module for some node classes. More nodes in scoped_nodes.py""" import abc import builtins as builtins_mod @@ -791,7 +788,7 @@ class NodeNG: indent=" ", max_depth=0, max_width=80, - ): + ) -> str: """Get a string representation of the AST from this node. :param ids: If true, includes the ids with the node type names. @@ -820,7 +817,7 @@ class NodeNG: :returns: The string representation of the AST. :rtype: str """ - # pylint: disable=too-many-statements + @_singledispatch def _repr_tree(node, result, done, cur_indent="", depth=1): """Outputs a representation of a non-tuple/list, non-node that's @@ -1630,8 +1627,6 @@ class Arguments(mixins.AssignTypeMixin, NodeNG): self.type_comment_kwonlyargs = type_comment_kwonlyargs self.type_comment_posonlyargs = type_comment_posonlyargs - # pylint: disable=too-many-arguments - def _infer_name(self, frame, name): if self.parent is frame: return name diff --git a/astroid/protocols.py b/astroid/protocols.py index b4c44444..ee31665e 100644 --- a/astroid/protocols.py +++ b/astroid/protocols.py @@ -603,7 +603,7 @@ def starred_assigned_stmts(self, node=None, context=None, assign_path=None): A list of indices, where each index specifies what item to fetch from the inference results. """ - # pylint: disable=too-many-locals,too-many-branches,too-many-statements + # pylint: disable=too-many-locals,too-many-statements def _determine_starred_iteration_lookups(starred, target, lookups): # Determine the lookups for the rhs of the iteration itered = target.itered() diff --git a/astroid/raw_building.py b/astroid/raw_building.py index 58a81964..b8bdc7a7 100644 --- a/astroid/raw_building.py +++ b/astroid/raw_building.py @@ -426,7 +426,6 @@ def _astroid_bootstrapping(): builder = InspectBuilder() astroid_builtin = builder.inspect_build(builtins) - # pylint: disable=redefined-outer-name for cls, node_cls in node_classes.CONST_CLS.items(): if cls is TYPE_NONE: proxy = build_class("NoneType") @@ -455,7 +454,6 @@ def _astroid_bootstrapping(): builder.object_build(bases.Generator._proxied, types.GeneratorType) if hasattr(types, "AsyncGeneratorType"): - # pylint: disable=no-member; AsyncGeneratorType _AsyncGeneratorType = nodes.ClassDef( types.AsyncGeneratorType.__name__, types.AsyncGeneratorType.__doc__ ) diff --git a/astroid/scoped_nodes.py b/astroid/scoped_nodes.py index 431e6c0f..9dff37a8 100644 --- a/astroid/scoped_nodes.py +++ b/astroid/scoped_nodes.py @@ -1485,7 +1485,6 @@ class FunctionDef(mixins.MultiLineBlockMixin, node_classes.Statement, Lambda): decorators.append(assign.value) return decorators - # pylint: disable=invalid-overridden-method @decorators_mod.cachedproperty def type( self, diff --git a/astroid/util.py b/astroid/util.py index 8cbdc810..8d9314a3 100644 --- a/astroid/util.py +++ b/astroid/util.py @@ -82,7 +82,6 @@ class BadUnaryOperationMessage(BadOperationMessage): return helpers.object_type def _object_type(self, obj): - # pylint: disable=not-callable; can't infer lazy_import objtype = self._object_type_helper(obj) if objtype is Uninferable: return None @@ -86,11 +86,10 @@ disable=fixme, too-many-public-methods, too-many-boolean-expressions, too-many-branches, + too-many-lines, # https://github.com/PyCQA/astroid/issues/465 too-many-statements, # We know about it and we're doing our best to remove it in 2.0 (oups) cyclic-import, - wrong-import-position, - wrong-import-order, # The check is faulty in most cases and it doesn't take in # account how the variable is being used. For instance, # using a variable that is a list or a generator in an @@ -114,8 +113,7 @@ disable=fixme, # everything here is legacy not checked in astroid/brain duplicate-code, -enable= - useless-suppression +enable=useless-suppression [BASIC] diff --git a/tests/unittest_inference.py b/tests/unittest_inference.py index 1889ba1b..0a3368f6 100644 --- a/tests/unittest_inference.py +++ b/tests/unittest_inference.py @@ -33,9 +33,8 @@ # Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html # For details: https://github.com/PyCQA/astroid/blob/master/LICENSE -"""tests for the astroid inference capabilities -""" -# pylint: disable=too-many-lines +"""Tests for the astroid inference capabilities""" + import platform import sys import textwrap |
