Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions astroid/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from __future__ import annotations

import warnings
from collections.abc import Generator

from astroid import bases, manager, nodes, objects, raw_building, util
Expand All @@ -20,20 +19,7 @@
)
from astroid.nodes import scoped_nodes
from astroid.typing import InferenceResult
from astroid.util import safe_infer as real_safe_infer


def safe_infer(
node: nodes.NodeNG | bases.Proxy | util.UninferableBase,
context: InferenceContext | None = None,
) -> InferenceResult | None:
# When removing, also remove the real_safe_infer alias
warnings.warn(
"Import safe_infer from astroid.util; this shim in astroid.helpers will be removed.",
DeprecationWarning,
stacklevel=2,
)
return real_safe_infer(node, context=context)
from astroid.util import safe_infer


def _build_proxy_class(cls_name: str, builtins: nodes.Module) -> nodes.ClassDef:
Expand Down Expand Up @@ -177,7 +163,7 @@ def has_known_bases(klass, context: InferenceContext | None = None) -> bool:
except AttributeError:
pass
for base in klass.bases:
result = real_safe_infer(base, context=context)
result = safe_infer(base, context=context)
# TODO: check for A->B->A->B pattern in class structure too?
if (
not isinstance(result, scoped_nodes.ClassDef)
Expand Down Expand Up @@ -250,7 +236,7 @@ def object_len(node, context: InferenceContext | None = None):
# pylint: disable=import-outside-toplevel; circular import
from astroid.objects import FrozenSet

inferred_node = real_safe_infer(node, context=context)
inferred_node = safe_infer(node, context=context)

# prevent self referential length calls from causing a recursion error
# see https://github.com/pylint-dev/astroid/issues/777
Expand Down
8 changes: 1 addition & 7 deletions astroid/nodes/node_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ def is_argument(self, name) -> bool:
return True
return self.find_argname(name)[1] is not None

def find_argname(self, argname, rec=DEPRECATED_ARGUMENT_DEFAULT):
def find_argname(self, argname):
"""Get the index and :class:`AssignName` node for given name.

:param argname: The name of the argument to search for.
Expand All @@ -977,12 +977,6 @@ def find_argname(self, argname, rec=DEPRECATED_ARGUMENT_DEFAULT):
:returns: The index and node for the argument.
:rtype: tuple(str or None, AssignName or None)
"""
if rec != DEPRECATED_ARGUMENT_DEFAULT: # pragma: no cover
warnings.warn(
"The rec argument will be removed in astroid 3.1.",
DeprecationWarning,
stacklevel=2,
)
if self.arguments:
index, argument = _find_arg(argname, self.arguments)
if argument:
Expand Down
13 changes: 0 additions & 13 deletions astroid/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,6 @@ def __str__(self) -> str:
return msg.format(self.op, self.left_type.name, self.right_type.name)


def _instancecheck(cls, other) -> bool:
wrapped = cls.__wrapped__
other_cls = other.__class__
is_instance_of = wrapped is other_cls or issubclass(other_cls, wrapped)
warnings.warn(
"%r is deprecated and slated for removal in astroid "
"2.0, use %r instead" % (cls.__class__.__name__, wrapped.__name__),
PendingDeprecationWarning,
stacklevel=2,
)
return is_instance_of


def check_warnings_filter() -> bool:
"""Return True if any other than the default DeprecationWarning filter is enabled.

Expand Down
Loading