Skip to content

Commit

Permalink
Enable checks for and fix useless suppression
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Sassoulas committed Apr 18, 2021
1 parent 58b3fae commit 98f1eff
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ astroid.egg-info/
.eggs/
.pytest_cache/
.mypy_cache/
venv
8 changes: 2 additions & 6 deletions astroid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,16 @@

import wrapt

from .__pkginfo__ import version as __version__

_Context = enum.Enum("Context", "Load Store Del")
Load = _Context.Load
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 *
Expand Down
2 changes: 1 addition & 1 deletion astroid/brain/brain_builtin_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def _extend_builtins(class_transforms):


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)
Expand Down
2 changes: 1 addition & 1 deletion astroid/brain/brain_namedtuple_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion astroid/modutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
import platform
import sys

# pylint: disable=import-error, no-name-in-module
# We don't want distutils to be a requirement
# pylint: disable=import-error, no-name-in-module,useless-suppression
from distutils.errors import DistutilsPlatformError
from distutils.sysconfig import get_python_lib # pylint: disable=import-error

Expand Down
11 changes: 3 additions & 8 deletions astroid/node_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -791,7 +788,7 @@ def repr_tree(
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.
Expand Down Expand Up @@ -820,7 +817,7 @@ def repr_tree(
: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
Expand Down Expand Up @@ -1630,8 +1627,6 @@ def postinit(
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
Expand Down
2 changes: 1 addition & 1 deletion astroid/protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 0 additions & 2 deletions astroid/raw_building.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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__
)
Expand Down
1 change: 0 additions & 1 deletion astroid/scoped_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1485,7 +1485,6 @@ def extra_decorators(self):
decorators.append(assign.value)
return decorators

# pylint: disable=invalid-overridden-method
@decorators_mod.cachedproperty
def type(
self,
Expand Down
1 change: 0 additions & 1 deletion astroid/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def _object_type_helper(self):
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
Expand Down
6 changes: 2 additions & 4 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -114,8 +113,7 @@ disable=fixme,
# everything here is legacy not checked in astroid/brain
duplicate-code,

enable=
useless-suppression
enable=useless-suppression

[BASIC]

Expand Down
5 changes: 2 additions & 3 deletions tests/unittest_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 98f1eff

Please sign in to comment.