Skip to content

Commit

Permalink
fix form errors in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mkurnikov committed Feb 20, 2019
1 parent 194258a commit 2d3b549
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions django-stubs/forms/formsets.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class BaseFormSet(Sized, Mapping[str, Any]):
def management_form(self): ...
def total_form_count(self): ...
def initial_form_count(self): ...
@property
def forms(self): ...
def get_form_kwargs(self, index: Any): ...
@property
Expand Down
13 changes: 5 additions & 8 deletions django-stubs/forms/models.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from collections import OrderedDict
from datetime import date, datetime
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type, Union, Sequence, MutableMapping
from typing import Any, Callable, Dict, Iterator, List, MutableMapping, Optional, Sequence, Tuple, Type, Union
from unittest.mock import MagicMock
from uuid import UUID

from django.core.files.base import File
from django.core.files.uploadedfile import SimpleUploadedFile
from django.db import models
from django.db.models import ForeignKey
from django.db.models.base import Model
Expand All @@ -16,9 +15,7 @@ from django.forms.fields import CharField, ChoiceField, Field
from django.forms.forms import BaseForm, DeclarativeFieldsMetaclass
from django.forms.formsets import BaseFormSet
from django.forms.utils import ErrorList
from django.forms.widgets import Input, Widget, Select
from django.http.request import QueryDict
from django.utils.datastructures import MultiValueDict
from django.forms.widgets import Input, Widget
from typing_extensions import Literal

ALL_FIELDS: str
Expand Down Expand Up @@ -97,7 +94,7 @@ def modelform_factory(
help_texts: Optional[MutableMapping[str, str]] = ...,
error_messages: Optional[MutableMapping[str, Dict[str, Any]]] = ...,
field_classes: Optional[MutableMapping[str, Type[Field]]] = ...,
) -> ModelForm: ...
) -> Type[ModelForm]: ...

class BaseModelFormSet(BaseFormSet):
model: Any = ...
Expand Down Expand Up @@ -155,7 +152,7 @@ def modelformset_factory(
error_messages: Optional[Dict[str, Dict[str, str]]] = ...,
validate_min: bool = ...,
field_classes: Optional[Dict[str, Type[Field]]] = ...,
) -> BaseModelFormSet: ...
) -> Type[BaseModelFormSet]: ...

class BaseInlineFormSet(BaseModelFormSet):
instance: Any = ...
Expand Down Expand Up @@ -200,7 +197,7 @@ def inlineformset_factory(
min_num: Optional[int] = ...,
validate_min: bool = ...,
field_classes: Optional[Dict[str, Any]] = ...,
) -> Any: ...
) -> Type[BaseInlineFormSet]: ...

class InlineForeignKeyField(Field):
disabled: bool
Expand Down
6 changes: 6 additions & 0 deletions scripts/typecheck_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@
+ 'base class "ImageFieldTestMixin" defined the type as "Type[PersonWithHeightAndWidth]")',
'note: "Person" defined here'
],
'model_formsets': [
'Incompatible types in string interpolation (expression has type "object", placeholder has type "Union[int, float]")'
],
'model_formsets_regress': [
'Incompatible types in assignment (expression has type "Model", variable has type "User")'
],
'model_regress': [
'Too many arguments for "Worker"',
re.compile(r'Incompatible type for "[a-z]+" of "Worker" \(got "int", expected')
Expand Down

0 comments on commit 2d3b549

Please sign in to comment.