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 base_field type for SimpleArrayField #1097

Merged
merged 2 commits into from
Aug 10, 2022
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
8 changes: 4 additions & 4 deletions django-stubs/contrib/postgres/forms/array.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ from ..utils import prefix_validation_error as prefix_validation_error

class SimpleArrayField(forms.CharField):
default_error_messages: _ErrorMessagesT = ...
base_field: Type[forms.Field]
base_field: forms.Field
delimiter: str
min_length: Optional[int]
max_length: Optional[int]
def __init__(
self,
base_field: Type[forms.Field],
base_field: forms.Field,
*,
delimiter: str = ...,
max_length: Optional[int] = ...,
Expand Down Expand Up @@ -51,11 +51,11 @@ class SplitArrayWidget(forms.Widget):

class SplitArrayField(forms.Field):
default_error_messages: _ErrorMessagesT = ...
base_field: Type[forms.Field]
base_field: forms.Field
size: int
remove_trailing_nulls: bool
def __init__(
self, base_field: Type[forms.Field], size: int, *, remove_trailing_nulls: bool = ..., **kwargs: Any
self, base_field: forms.Field, size: int, *, remove_trailing_nulls: bool = ..., **kwargs: Any
) -> None: ...
def to_python(self, value: Any) -> Sequence[Any]: ...
def clean(self, value: Any) -> Sequence[Any]: ...
Expand Down
15 changes: 15 additions & 0 deletions tests/typecheck/contrib/postgres/test_fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,18 @@

class MyModel(models.Model):
array = ArrayField(base_field=models.TextField())
- case: postgres_forms_simple_array_field
main: |
from myapp.forms import MyForm
MyForm()
installed_apps:
- myapp
files:
- path: myapp/__init__.py
- path: myapp/forms.py
content: |
from django import forms
from django.contrib.postgres.forms import SimpleArrayField

class MyForm(forms.Form):
lots_of_dates = SimpleArrayField(forms.DateField(), required=False)