Attempt to fix 'INTERNAL ERROR using annotate'. (#753)

KeyError: "Failed qualified lookup: '_AnyAttrAllowed' (fullname =
'django._AnyAttrAllowed')."

https://github.com/typeddjango/django-stubs/issues/745
This commit is contained in:
Seth Yastrov
2022-01-28 19:43:03 +01:00
committed by GitHub
parent 28d6dc992c
commit c556668d7a
4 changed files with 14 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
from typing import Any, Protocol from typing import Any
from .utils.version import get_version as get_version from .utils.version import get_version as get_version
@@ -6,8 +6,3 @@ VERSION: Any
__version__: str __version__: str
def setup(set_prefix: bool = ...) -> None: ... def setup(set_prefix: bool = ...) -> None: ...
# Used internally by mypy_django_plugin.
class _AnyAttrAllowed(Protocol):
def __getattr__(self, item: str) -> Any: ...
def __setattr__(self, item: str, value: Any) -> None: ...

View File

@@ -2,5 +2,6 @@ from .aliases import ValuesQuerySet as ValuesQuerySet
from .annotations import Annotations as Annotations from .annotations import Annotations as Annotations
from .annotations import WithAnnotations as WithAnnotations from .annotations import WithAnnotations as WithAnnotations
from .patch import monkeypatch as monkeypatch from .patch import monkeypatch as monkeypatch
from .types import AnyAttrAllowed as AnyAttrAllowed
__all__ = ["monkeypatch", "ValuesQuerySet", "WithAnnotations", "Annotations"] __all__ = ["monkeypatch", "ValuesQuerySet", "WithAnnotations", "Annotations", "AnyAttrAllowed"]

View File

@@ -0,0 +1,10 @@
from typing import Any, Protocol
# Used internally by mypy_django_plugin.
class AnyAttrAllowed(Protocol):
def __getattr__(self, item: str) -> Any:
...
def __setattr__(self, item: str, value: Any) -> None:
...

View File

@@ -38,4 +38,4 @@ HTTPREQUEST_CLASS_FULLNAME = "django.http.request.HttpRequest"
F_EXPRESSION_FULLNAME = "django.db.models.expressions.F" F_EXPRESSION_FULLNAME = "django.db.models.expressions.F"
ANY_ATTR_ALLOWED_CLASS_FULLNAME = "django._AnyAttrAllowed" ANY_ATTR_ALLOWED_CLASS_FULLNAME = "django_stubs_ext.AnyAttrAllowed"