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

Add through_defaults for RelatedManager methods #1943

Merged
merged 2 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 18 additions & 4 deletions django-stubs/db/models/fields/related_descriptors.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,26 @@ class ManyToManyDescriptor(ReverseManyToOneDescriptor, Generic[_To, _Through]):
@type_check_only
class ManyRelatedManager(Manager[_M], Generic[_M]):
related_val: tuple[int, ...]
def add(self, *objs: _M | int, bulk: bool = ...) -> None: ...
async def aadd(self, *objs: _M | int, bulk: bool = ...) -> None: ...
def add(self, *objs: _M | int, bulk: bool = ..., through_defaults: dict[str, Any] | None = ...) -> None: ...
async def aadd(self, *objs: _M | int, bulk: bool = ..., through_defaults: dict[str, Any] | None = ...) -> None: ...
def remove(self, *objs: _M | int, bulk: bool = ...) -> None: ...
async def aremove(self, *objs: _M | int, bulk: bool = ...) -> None: ...
def set(self, objs: QuerySet[_M] | Iterable[_M | int], *, bulk: bool = ..., clear: bool = ...) -> None: ...
async def aset(self, objs: QuerySet[_M] | Iterable[_M | int], *, bulk: bool = ..., clear: bool = ...) -> None: ...
def set(
self,
objs: QuerySet[_M] | Iterable[_M | int],
*,
bulk: bool = ...,
clear: bool = ...,
through_defaults: dict[str, Any] | None = ...,
) -> None: ...
async def aset(
self,
objs: QuerySet[_M] | Iterable[_M | int],
*,
bulk: bool = ...,
clear: bool = ...,
through_defaults: dict[str, Any] | None = ...,
) -> None: ...
def clear(self) -> None: ...
async def aclear(self) -> None: ...
def __call__(self, *, manager: str) -> ManyRelatedManager[_M]: ...
Expand Down
2 changes: 1 addition & 1 deletion tests/typecheck/fields/test_related.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@
main:26: note: Revealed type is "myapp.models.MyModel_auto_through"
main:28: note: Revealed type is "builtins.str"
main:29: note: Revealed type is "builtins.str"
main:30: note: Revealed type is "def (*objs: Union[myapp.models.MyModel, builtins.int], bulk: builtins.bool =)"
main:30: note: Revealed type is "def (*objs: Union[myapp.models.MyModel, builtins.int], bulk: builtins.bool =, through_defaults: Union[builtins.dict[builtins.str, Any], None] =)"
installed_apps:
- myapp
files:
Expand Down