Skip to content

Commit

Permalink
Refine return type for ManyToOneRel.get_accessor_name() (#2052)
Browse files Browse the repository at this point in the history
Only for the special case of a symmetrical m2m relation on self,
`ForeignObjectRel.get_accessor_name()` will return `None`. However,
`ManyToOneRel` and its subclasses will never be symmetrical, so for
those classes `get_accessor_name()` does not return `None`.
  • Loading branch information
mthuurne committed Apr 10, 2024
1 parent 93994a1 commit 7bace0d
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions django-stubs/db/models/fields/reverse_related.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class ManyToOneRel(ForeignObjectRel):
on_delete: Callable = ...,
) -> None: ...
def get_related_field(self) -> Field: ...
def get_accessor_name(self, model: type[Model] | None = ...) -> str: ...

class OneToOneRel(ManyToOneRel):
field: OneToOneField
Expand Down

0 comments on commit 7bace0d

Please sign in to comment.