diff options
Diffstat (limited to 'astroid')
-rw-r--r-- | astroid/bases.py | 10 | ||||
-rw-r--r-- | astroid/util.py | 23 |
2 files changed, 8 insertions, 25 deletions
diff --git a/astroid/bases.py b/astroid/bases.py index 6a4c3191..9bb90728 100644 --- a/astroid/bases.py +++ b/astroid/bases.py @@ -33,7 +33,7 @@ from astroid.typing import ( InferenceResult, SuccessfulInferenceResult, ) -from astroid.util import Uninferable, UninferableBase, lazy_descriptor +from astroid.util import Uninferable, UninferableBase if TYPE_CHECKING: from astroid.constraint import Constraint @@ -633,7 +633,10 @@ class Generator(BaseInstance): Proxied class is set once for all in raw_building. """ - special_attributes = lazy_descriptor(objectmodel.GeneratorModel) + # We defer initialization of special_attributes to the __init__ method since the constructor + # of GeneratorModel requires the raw_building to be complete + # TODO: This should probably be refactored. + special_attributes: objectmodel.GeneratorModel def __init__( self, parent=None, generator_initial_context: InferenceContext | None = None @@ -642,6 +645,9 @@ class Generator(BaseInstance): self.parent = parent self._call_context = copy_context(generator_initial_context) + # See comment above: this is a deferred initialization. + Generator.special_attributes = objectmodel.GeneratorModel() + def infer_yield_types(self): yield from self.parent.infer_yield_result(self._call_context) diff --git a/astroid/util.py b/astroid/util.py index d2564f30..50ca336a 100644 --- a/astroid/util.py +++ b/astroid/util.py @@ -8,16 +8,6 @@ from __future__ import annotations import warnings from typing import Any, Final, Literal -import lazy_object_proxy - - -def lazy_descriptor(obj): - class DescriptorProxy(lazy_object_proxy.Proxy): - def __get__(self, instance, owner=None): - return self.__class__.__get__(self, instance) - - return DescriptorProxy(obj) - class UninferableBase: """Special inference object, which is returned when inference fails. @@ -124,19 +114,6 @@ def _instancecheck(cls, other) -> bool: return is_instance_of -def proxy_alias(alias_name, node_type): - """Get a Proxy from the given name to the given node type.""" - proxy = type( - alias_name, - (lazy_object_proxy.Proxy,), - { - "__class__": object.__dict__["__class__"], - "__instancecheck__": _instancecheck, - }, - ) - return proxy(lambda: node_type) - - def check_warnings_filter() -> bool: """Return True if any other than the default DeprecationWarning filter is enabled. |