Skip to content

Commit

Permalink
Remove caching layer
Browse files Browse the repository at this point in the history
  • Loading branch information
Rebecca Turner committed Jul 27, 2021
1 parent 4adf6bd commit 3a12ebe
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions pylint/checkers/design_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@

"""check for signs of poor design"""

import functools
import re
from collections import defaultdict
from typing import List, Set, Tuple, cast
from typing import FrozenSet, List, Set, cast

import astroid
from astroid import nodes
Expand Down Expand Up @@ -240,7 +239,7 @@ def _count_methods_in_class(node):


def _get_parents(
node: nodes.ClassDef, ignored_parents: Set[str]
node: nodes.ClassDef, ignored_parents: FrozenSet[str]
) -> Set[nodes.ClassDef]:
r"""Get parents of ``node``, excluding ancestors of ``ignored_parents``.
Expand Down Expand Up @@ -268,20 +267,6 @@ def _get_parents(
return parents


@functools.lru_cache(maxsize=32)
def _combine_tuples_to_set(
tuple_1: Tuple[str, ...], tuple_2: Tuple[str, ...]
) -> Set[str]:
"""Combine two tuples into a set.
This is cached to avoid constructing a set for every call of
:any:`MisdesignChecker.visit_classdef`.
"""
ret = set(tuple_1)
ret.update(tuple_2)
return ret


class MisdesignChecker(BaseChecker):
"""checks for sign of poor/misdesign:
* number of methods, attributes, local variables...
Expand Down Expand Up @@ -434,10 +419,7 @@ def _ignored_argument_names(self):
def visit_classdef(self, node: nodes.ClassDef):
"""check size of inheritance hierarchy and number of instance attributes"""
parents = _get_parents(
node,
_combine_tuples_to_set(
STDLIB_CLASSES_IGNORE_ANCESTOR, self.config.ignored_parents
),
node, STDLIB_CLASSES_IGNORE_ANCESTOR.union(self.config.ignored_parents)
)
print(parents)
nb_parents = len(parents)
Expand Down

0 comments on commit 3a12ebe

Please sign in to comment.