Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse functools.cached_property definition instead of defining our own #1771

Merged
merged 6 commits into from
Oct 24, 2023
Merged
Changes from 1 commit
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
Next Next commit
Reuse functools.cached_property definition instead of defining our own
  • Loading branch information
intgr committed Oct 15, 2023
commit 903262b0ba57689cc9d3b38d099f4c454acdb4de
13 changes: 3 additions & 10 deletions django-stubs/utils/functional.pyi
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
from collections.abc import Callable, Sequence

# Mypy has special handling for functools.cached_property, reuse typeshed's definition instead of defining our own
from functools import cached_property as cached_property
from typing import Any, Generic, Protocol, SupportsIndex, TypeVar, overload

from django.db.models.base import Model
from typing_extensions import Self, TypeAlias

_T = TypeVar("_T")

class cached_property(Generic[_T]):
func: Callable[[Any], _T]
name: str | None
def __init__(self, func: Callable[[Any], _T], name: str | None = ...) -> None: ...
@overload
def __get__(self, instance: None, cls: type[Any] | None = ...) -> Self: ...
@overload
def __get__(self, instance: object, cls: type[Any] | None = ...) -> _T: ...
def __set_name__(self, owner: type[Any], name: str) -> None: ...

# Promise is only subclassed by a proxy class defined in the lazy function
# so it makes sense for it to have all the methods available in that proxy class
class Promise:
Expand Down
Loading