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

Fix typing of related manager methods #2439

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ngnpope
Copy link
Contributor

@ngnpope ngnpope commented Nov 7, 2024

Looking at the related manager documentation it isn't very clear that the bulk argument only applies to RelatedManager and the through_defaults argument only applies to ManyRelatedManager.

Based on the related descriptors source, the following changes have been made in this commit:

  • The bulk argument has been added to .clear() and .aclear() for RelatedManager
  • The bulk argument has been removed from all methods of ManyRelatedManager
  • Additional methods using through_defaults have been added to ManyRelatedManager.

@ngnpope ngnpope force-pushed the fix-related-managers branch 3 times, most recently from 8f45820 to 2dd86ee Compare November 7, 2024 18:00
Looking at the [related manager documentation][0] it isn't very clear
that the `bulk` argument only applies to `RelatedManager` and the
`through_defaults` argument only applies to `ManyRelatedManager`.

Based on the [related descriptors source][1], the following changes have
been made in this commit:

- The `bulk` argument has been added to `.clear()` and `.aclear()` for
  `RelatedManager`
- The `bulk` argument has been removed from all methods of
  `ManyRelatedManager`
- Additional methods using `through_defaults` have been added to
  `ManyRelatedManager`.
- Updated typing of `through_defaults` to `Mapping[str, Any] | None`

[0]: https://docs.djangoproject.com/en/stable/ref/models/relations/
[1]: https://github.com/django/django/blob/042b381e2e37c0c37b8a8f6cc9947f1a2ebfa0dd/django/db/models/fields/related_descriptors.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant