SILENT KILLERPanel

Current Path: > > opt > cloudlinux > venv > lib > > python3.11 > site-packages > astroid >


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: //opt/cloudlinux/venv/lib//python3.11/site-packages/astroid/

NameTypeSizeLast ModifiedActions
__pycache__ Directory - -
brain Directory - -
interpreter Directory - -
nodes Directory - -
__init__.py File 5104 bytes April 17 2025 13:10:59.
__pkginfo__.py File 274 bytes April 17 2025 13:10:59.
_ast.py File 4146 bytes April 17 2025 13:10:59.
_backport_stdlib_names.py File 7016 bytes April 17 2025 13:10:59.
_cache.py File 786 bytes April 17 2025 13:10:59.
arguments.py File 12958 bytes April 17 2025 13:10:59.
astroid_manager.py File 572 bytes April 17 2025 13:10:59.
bases.py File 25594 bytes April 17 2025 13:10:59.
builder.py File 18788 bytes April 17 2025 13:10:59.
const.py File 1095 bytes April 17 2025 13:10:59.
constraint.py File 5043 bytes April 17 2025 13:10:59.
context.py File 5994 bytes April 17 2025 13:10:59.
decorators.py File 10090 bytes April 17 2025 13:10:59.
exceptions.py File 13089 bytes April 17 2025 13:10:59.
filter_statements.py File 9643 bytes April 17 2025 13:10:59.
helpers.py File 11336 bytes April 17 2025 13:10:59.
inference.py File 45121 bytes April 17 2025 13:10:59.
inference_tip.py File 2888 bytes April 17 2025 13:10:59.
manager.py File 17960 bytes April 17 2025 13:10:59.
mixins.py File 1182 bytes April 17 2025 13:10:59.
modutils.py File 23508 bytes April 17 2025 13:10:59.
node_classes.py File 1840 bytes April 17 2025 13:10:59.
objects.py File 12757 bytes April 17 2025 13:10:59.
protocols.py File 32976 bytes April 17 2025 13:10:59.
raw_building.py File 22875 bytes April 17 2025 13:10:59.
rebuilder.py File 79731 bytes April 17 2025 13:10:59.
scoped_nodes.py File 958 bytes April 17 2025 13:10:59.
test_utils.py File 2434 bytes April 17 2025 13:10:59.
transforms.py File 3271 bytes April 17 2025 13:10:59.
typing.py File 1983 bytes April 17 2025 13:10:59.
util.py File 4729 bytes April 17 2025 13:10:59.

Reading File: //opt/cloudlinux/venv/lib//python3.11/site-packages/astroid//inference_tip.py

# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
# For details: https://github.com/PyCQA/astroid/blob/main/LICENSE
# Copyright (c) https://github.com/PyCQA/astroid/blob/main/CONTRIBUTORS.txt

"""Transform utilities (filters and decorator)."""

from __future__ import annotations

import typing
from collections.abc import Iterator

import wrapt

from astroid.exceptions import InferenceOverwriteError, UseInferenceDefault
from astroid.nodes import NodeNG
from astroid.typing import InferenceResult, InferFn

_cache: dict[tuple[InferFn, NodeNG], list[InferenceResult] | None] = {}


def clear_inference_tip_cache() -> None:
    """Clear the inference tips cache."""
    _cache.clear()


@wrapt.decorator
def _inference_tip_cached(
    func: InferFn, instance: None, args: typing.Any, kwargs: typing.Any
) -> Iterator[InferenceResult]:
    """Cache decorator used for inference tips."""
    node = args[0]
    try:
        result = _cache[func, node]
        # If through recursion we end up trying to infer the same
        # func + node we raise here.
        if result is None:
            raise UseInferenceDefault()
    except KeyError:
        _cache[func, node] = None
        result = _cache[func, node] = list(func(*args, **kwargs))
        assert result
    return iter(result)


def inference_tip(infer_function: InferFn, raise_on_overwrite: bool = False) -> InferFn:
    """Given an instance specific inference function, return a function to be
    given to AstroidManager().register_transform to set this inference function.

    :param bool raise_on_overwrite: Raise an `InferenceOverwriteError`
        if the inference tip will overwrite another. Used for debugging

    Typical usage

    .. sourcecode:: python

       AstroidManager().register_transform(Call, inference_tip(infer_named_tuple),
                                  predicate)

    .. Note::

        Using an inference tip will override
        any previously set inference tip for the given
        node. Use a predicate in the transform to prevent
        excess overwrites.
    """

    def transform(node: NodeNG, infer_function: InferFn = infer_function) -> NodeNG:
        if (
            raise_on_overwrite
            and node._explicit_inference is not None
            and node._explicit_inference is not infer_function
        ):
            raise InferenceOverwriteError(
                "Inference already set to {existing_inference}. "
                "Trying to overwrite with {new_inference} for {node}".format(
                    existing_inference=infer_function,
                    new_inference=node._explicit_inference,
                    node=node,
                )
            )
        # pylint: disable=no-value-for-parameter
        node._explicit_inference = _inference_tip_cached(infer_function)
        return node

    return transform

SILENT KILLER Tool