diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2023-04-24 23:22:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-24 23:22:28 +0200 |
commit | aba2587b8ddc105d4c537dd900fd76fec789364c (patch) | |
tree | bb710c3082913fc57872836929efe17f3ff4a56e | |
parent | 75b4e73b3d3d854ffeda95f44889dc9b5d9dafca (diff) | |
download | astroid-git-aba2587b8ddc105d4c537dd900fd76fec789364c.tar.gz |
Remove ``laxy_object_proxy`` as dependency (#2139)
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | astroid/bases.py | 10 | ||||
-rw-r--r-- | astroid/util.py | 23 | ||||
-rw-r--r-- | pyproject.toml | 2 |
4 files changed, 11 insertions, 27 deletions
@@ -75,6 +75,9 @@ Release date: TBA * Remove dependency on ``wrapt``. +* Remove dependency on ``lazy_object_proxy``. This includes the removal + of the assosicated ``lazy_import``, ``lazy_descriptor`` and ``proxy_alias`` utility functions. + * ``CallSite._unpack_args`` and ``CallSite._unpack_keywords`` now use ``safe_infer()`` for better inference and fewer false positives. 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. diff --git a/pyproject.toml b/pyproject.toml index dd136823..78da1117 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,6 @@ classifiers = [ ] requires-python = ">=3.8.0" dependencies = [ - "lazy_object_proxy>=1.4.0", "typing-extensions>=4.0.0;python_version<'3.11'", ] dynamic = ["version"] @@ -71,7 +70,6 @@ module = [ "_io.*", "gi.*", "importlib.*", - "lazy_object_proxy.*", "nose.*", "numpy.*", "pytest", |