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

Type missing RelatedField.__init__ method #1816

Merged
merged 1 commit into from
Nov 5, 2023
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
39 changes: 34 additions & 5 deletions django-stubs/db/models/fields/related.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,36 @@ class RelatedField(FieldCacheMixin, Field[_ST, _GT]):
remote_field: ForeignObjectRel
rel_class: type[ForeignObjectRel]
swappable: bool
def __init__(
self,
related_name: str | None = ...,
related_query_name: str | None = ...,
limit_choices_to: _AllLimitChoicesTo | None = ...,
*,
verbose_name: _StrOrPromise | None = ...,
name: str | None = ...,
primary_key: bool = ...,
max_length: int | None = ...,
unique: bool = ...,
blank: bool = ...,
null: bool = ...,
db_index: bool = ...,
rel: ForeignObjectRel | None = ...,
default: Any = ...,
editable: bool = ...,
serialize: bool = ...,
unique_for_date: str | None = ...,
unique_for_month: str | None = ...,
unique_for_year: str | None = ...,
choices: _FieldChoices | None = ...,
help_text: _StrOrPromise = ...,
db_column: str | None = ...,
db_tablespace: str | None = ...,
auto_created: bool = ...,
validators: Iterable[validators._ValidatorCallable] = ...,
error_messages: _ErrorMessagesMapping | None = ...,
db_comment: str | None = ...,
) -> None: ...
@property
def related_model(self) -> type[Model] | Literal["self"]: ... # type: ignore[override]
def get_forward_related_filter(self, obj: Model) -> dict[str, int | UUID]: ...
Expand Down Expand Up @@ -73,7 +103,6 @@ class ForeignObject(RelatedField[_ST, _GT]):
parent_link: bool = ...,
swappable: bool = ...,
*,
db_constraint: bool = ...,
verbose_name: _StrOrPromise | None = ...,
name: str | None = ...,
primary_key: bool = ...,
Expand All @@ -88,10 +117,10 @@ class ForeignObject(RelatedField[_ST, _GT]):
choices: _FieldChoices | None = ...,
help_text: _StrOrPromise = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[validators._ValidatorCallable] = ...,
error_messages: _ErrorMessagesMapping | None = ...,
db_comment: str | None = ...,
) -> None: ...
# class access
@overload
Expand Down Expand Up @@ -147,10 +176,10 @@ class ForeignKey(ForeignObject[_ST, _GT]):
choices: _FieldChoices | None = ...,
help_text: _StrOrPromise = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[validators._ValidatorCallable] = ...,
error_messages: _ErrorMessagesMapping | None = ...,
db_comment: str | None = ...,
) -> None: ...

class OneToOneField(ForeignKey[_ST, _GT]):
Expand Down Expand Up @@ -188,10 +217,10 @@ class OneToOneField(ForeignKey[_ST, _GT]):
choices: _FieldChoices | None = ...,
help_text: _StrOrPromise = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[validators._ValidatorCallable] = ...,
error_messages: _ErrorMessagesMapping | None = ...,
db_comment: str | None = ...,
) -> None: ...
# class access
@overload
Expand Down Expand Up @@ -247,9 +276,9 @@ class ManyToManyField(RelatedField[Any, Any], Generic[_To, _M]):
choices: _FieldChoices | None = ...,
help_text: _StrOrPromise = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
error_messages: _ErrorMessagesMapping | None = ...,
db_comment: str | None = ...,
) -> None: ...
# class access
@overload
Expand Down
1 change: 0 additions & 1 deletion scripts/stubtest/allowlist_todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,6 @@ django.db.models.fields.related.OneToOneField.formfield
django.db.models.fields.related.OneToOneField.forward_related_accessor_class
django.db.models.fields.related.OneToOneField.related_accessor_class
django.db.models.fields.related.OneToOneRel.__init__
django.db.models.fields.related.RelatedField.__init__
django.db.models.fields.related.RelatedField.formfield
django.db.models.fields.related.RelatedField.related_model
django.db.models.fields.related.ReverseManyToOneDescriptor.related_manager_cls
Expand Down