diff options
Diffstat (limited to 'pylint/pyreverse/inspector.py')
-rw-r--r-- | pylint/pyreverse/inspector.py | 53 |
1 files changed, 4 insertions, 49 deletions
diff --git a/pylint/pyreverse/inspector.py b/pylint/pyreverse/inspector.py index 523ff8171..0cabe9473 100644 --- a/pylint/pyreverse/inspector.py +++ b/pylint/pyreverse/inspector.py @@ -1,6 +1,6 @@ # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE -# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt +# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE +# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt """Visitor doing some post-processing on the astroid tree. @@ -12,13 +12,11 @@ from __future__ import annotations import collections import os import traceback -import warnings from abc import ABC, abstractmethod -from collections.abc import Generator -from typing import Any, Callable, Optional +from typing import Callable, Optional import astroid -from astroid import nodes, util +from astroid import nodes from pylint import constants from pylint.pyreverse import utils @@ -39,27 +37,6 @@ def _astroid_wrapper( return None -def interfaces(node: nodes.ClassDef) -> Generator[Any, None, None]: - """Return an iterator on interfaces implemented by the given class node.""" - try: - implements = astroid.bases.Instance(node).getattr("__implements__")[0] - except astroid.exceptions.NotFoundError: - return - if implements.frame(future=True) is not node: - return - found = set() - missing = False - for iface in nodes.unpack_infer(implements): - if isinstance(iface, util.UninferableBase): - missing = True - continue - if iface not in found: - found.add(iface) - yield iface - if missing: - raise astroid.exceptions.InferenceError() - - class IdGeneratorMixIn: """Mixin adding the ability to generate integer uid.""" @@ -129,9 +106,6 @@ class Linker(IdGeneratorMixIn, utils.LocalsVisitor): * aggregations_type as instance_attrs_type but for aggregations relationships - - * implements, - list of implemented interface _objects_ (only on astroid.Class nodes) """ def __init__(self, project: Project, tag: bool = False) -> None: @@ -172,7 +146,6 @@ class Linker(IdGeneratorMixIn, utils.LocalsVisitor): """Visit an astroid.Class node. * set the locals_type and instance_attrs_type mappings - * set the implements list and build it * optionally tag the node with a unique id """ if hasattr(node, "locals_type"): @@ -194,24 +167,6 @@ class Linker(IdGeneratorMixIn, utils.LocalsVisitor): if not isinstance(assignattr, nodes.Unknown): self.associations_handler.handle(assignattr, node) self.handle_assignattr_type(assignattr, node) - # resolve implemented interface - try: - ifaces = interfaces(node) - if ifaces is not None: - node.implements = list(ifaces) - if node.implements: - # TODO: 3.0: Remove support for __implements__ - warnings.warn( - "pyreverse will drop support for resolving and displaying " - "implemented interfaces in pylint 3.0. The implementation " - "relies on the '__implements__' attribute proposed in PEP 245" - ", which was rejected in 2006.", - DeprecationWarning, - ) - else: - node.implements = [] - except astroid.InferenceError: - node.implements = [] def visit_functiondef(self, node: nodes.FunctionDef) -> None: """Visit an astroid.Function node. |