mirror of
https://github.com/davidhalter/django-stubs.git
synced 2026-05-18 06:19:47 +08:00
Add test to import all modules to check validity of stubs (#56)
* add import_all.test builder * fix errors * fix typechecking errors * fix migrations typechecking
This commit is contained in:
@@ -21,7 +21,7 @@ class BaseForm:
|
||||
is_bound: bool = ...
|
||||
data: Dict[str, Any] = ...
|
||||
files: Optional[Dict[str, Any]] = ...
|
||||
auto_id: Any = ...
|
||||
auto_id: str = ...
|
||||
initial: Dict[str, Any] = ...
|
||||
error_class: Type[ErrorList] = ...
|
||||
prefix: str = ...
|
||||
@@ -59,7 +59,7 @@ class BaseForm:
|
||||
def add_error(self, field: Optional[str], error: Union[ValidationError, str]) -> None: ...
|
||||
def has_error(self, field: Any, code: Optional[Any] = ...): ...
|
||||
def full_clean(self) -> None: ...
|
||||
def clean(self) -> Dict[str, Optional[Union[datetime, SimpleUploadedFile, QuerySet, str]]]: ...
|
||||
def clean(self) -> Dict[str, Any]: ...
|
||||
def has_changed(self) -> bool: ...
|
||||
def changed_data(self) -> List[str]: ...
|
||||
@property
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
from collections import OrderedDict
|
||||
from datetime import date, datetime
|
||||
from typing import Any, Callable, Dict, Iterator, List, MutableMapping, Optional, Sequence, Tuple, Type, Union, Mapping
|
||||
from datetime import datetime
|
||||
from typing import Any, Callable, Dict, Iterator, List, Mapping, MutableMapping, Optional, Sequence, Tuple, Type, Union
|
||||
from unittest.mock import MagicMock
|
||||
from uuid import UUID
|
||||
|
||||
from django.core.files.base import File
|
||||
from django.db import models
|
||||
from django.db.models import ForeignKey
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.manager import Manager
|
||||
from django.db.models.query import QuerySet
|
||||
@@ -18,6 +15,9 @@ from django.forms.utils import ErrorList
|
||||
from django.forms.widgets import Input, Widget
|
||||
from typing_extensions import Literal
|
||||
|
||||
from django.db import models
|
||||
from django.db.models import ForeignKey
|
||||
|
||||
ALL_FIELDS: str
|
||||
|
||||
_Fields = Union[List[Union[Callable, str]], Sequence[str], Literal["__all__"]]
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
from datetime import time
|
||||
from decimal import Decimal
|
||||
from itertools import chain
|
||||
from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Sequence, Set, Tuple, Type, Union
|
||||
from typing import Any, Callable, Dict, Iterable, Iterator, List, Mapping, Optional, Sequence, Set, Tuple, Type, Union
|
||||
|
||||
from django.core.files.base import File
|
||||
from django.db.models.fields.files import FieldFile
|
||||
from django.forms.renderers import EngineMixin
|
||||
from django.utils.datastructures import MultiValueDict
|
||||
from django.utils.safestring import SafeText
|
||||
|
||||
_OptAttrs = Dict[str, str]
|
||||
_OptAttrs = Dict[str, Any]
|
||||
|
||||
class MediaOrderConflictWarning(RuntimeWarning): ...
|
||||
|
||||
@@ -38,31 +35,21 @@ class Widget:
|
||||
is_localized: bool = ...
|
||||
is_required: bool = ...
|
||||
supports_microseconds: bool = ...
|
||||
attrs: Dict[str, Any] = ...
|
||||
def __init__(self, attrs: Optional[Dict[str, Any]] = ...) -> None: ...
|
||||
attrs: _OptAttrs = ...
|
||||
def __init__(self, attrs: Optional[_OptAttrs] = ...) -> None: ...
|
||||
@property
|
||||
def is_hidden(self) -> bool: ...
|
||||
def subwidgets(
|
||||
self, name: str, value: Optional[List[str]], attrs: Dict[str, bool] = ...
|
||||
) -> Iterator[Dict[str, Any]]: ...
|
||||
def subwidgets(self, name: str, value: Optional[List[str]], attrs: _OptAttrs = ...) -> Iterator[Dict[str, Any]]: ...
|
||||
def format_value(self, value: Any) -> Optional[str]: ...
|
||||
def get_context(self, name: str, value: Any, attrs: Optional[Dict[str, Union[bool, str]]]) -> Dict[str, Any]: ...
|
||||
def get_context(self, name: str, value: Any, attrs: Optional[_OptAttrs]) -> Dict[str, Any]: ...
|
||||
def render(
|
||||
self,
|
||||
name: str,
|
||||
value: Any,
|
||||
attrs: Optional[Dict[str, Union[bool, str]]] = ...,
|
||||
renderer: Optional[EngineMixin] = ...,
|
||||
self, name: str, value: Any, attrs: Optional[_OptAttrs] = ..., renderer: Optional[EngineMixin] = ...
|
||||
) -> SafeText: ...
|
||||
def build_attrs(
|
||||
self, base_attrs: Dict[str, Union[float, str]], extra_attrs: Optional[Dict[str, Union[bool, str]]] = ...
|
||||
self, base_attrs: _OptAttrs, extra_attrs: Optional[_OptAttrs] = ...
|
||||
) -> Dict[str, Union[Decimal, float, str]]: ...
|
||||
def value_from_datadict(
|
||||
self, data: dict, files: Union[Dict[str, Iterable[Any]], MultiValueDict], name: str
|
||||
) -> Any: ...
|
||||
def value_omitted_from_data(
|
||||
self, data: Dict[str, Any], files: Union[Dict[str, Iterable[Any]], MultiValueDict], name: str
|
||||
) -> bool: ...
|
||||
def value_from_datadict(self, data: Dict[str, Any], files: Mapping[str, Iterable[Any]], name: str) -> Any: ...
|
||||
def value_omitted_from_data(self, data: Dict[str, Any], files: Mapping[str, Iterable[Any]], name: str) -> bool: ...
|
||||
def id_for_label(self, id_: str) -> str: ...
|
||||
def use_required_attribute(self, initial: Any) -> bool: ...
|
||||
|
||||
@@ -94,14 +81,12 @@ class ClearableFileInput(FileInput):
|
||||
def clear_checkbox_name(self, name: str) -> str: ...
|
||||
def clear_checkbox_id(self, name: str) -> str: ...
|
||||
def is_initial(self, value: Optional[Union[File, str]]) -> bool: ...
|
||||
def use_required_attribute(self, initial: Optional[Union[FieldFile, str]]) -> bool: ...
|
||||
|
||||
class Textarea(Widget):
|
||||
template_name: str = ...
|
||||
|
||||
class DateTimeBaseInput(TextInput):
|
||||
format_key: str = ...
|
||||
supports_microseconds: bool = ...
|
||||
format: Optional[str] = ...
|
||||
def __init__(self, attrs: Optional[_OptAttrs] = ..., format: Optional[str] = ...): ...
|
||||
|
||||
@@ -128,7 +113,7 @@ class ChoiceWidget(Widget):
|
||||
def create_option(
|
||||
self,
|
||||
name: str,
|
||||
value: Union[time, int, str],
|
||||
value: Any,
|
||||
label: Union[int, str],
|
||||
selected: Union[Set[str], bool],
|
||||
index: int,
|
||||
@@ -137,13 +122,7 @@ class ChoiceWidget(Widget):
|
||||
) -> Dict[str, Any]: ...
|
||||
def id_for_label(self, id_: str, index: str = ...) -> str: ...
|
||||
|
||||
class Select(ChoiceWidget):
|
||||
option_template_name: str = ...
|
||||
add_id_index: bool = ...
|
||||
checked_attribute: Any = ...
|
||||
option_inherits_attrs: bool = ...
|
||||
def use_required_attribute(self, initial: Any) -> bool: ...
|
||||
|
||||
class Select(ChoiceWidget): ...
|
||||
class NullBooleanSelect(Select): ...
|
||||
|
||||
class SelectMultiple(Select):
|
||||
@@ -154,40 +133,26 @@ class RadioSelect(ChoiceWidget):
|
||||
option_template_name: str = ...
|
||||
|
||||
class CheckboxSelectMultiple(ChoiceWidget):
|
||||
allow_multiple_selected: bool = ...
|
||||
option_template_name: str = ...
|
||||
def use_required_attribute(self, initial: Optional[List[str]]) -> bool: ...
|
||||
def id_for_label(self, id_: str, index: Optional[str] = ...) -> str: ...
|
||||
|
||||
class MultiWidget(Widget):
|
||||
template_name: str = ...
|
||||
widgets: List[Widget] = ...
|
||||
def __init__(self, widgets: Sequence[Union[Widget, Type[Widget]]], attrs: Optional[_OptAttrs] = ...) -> None: ...
|
||||
@property
|
||||
def is_hidden(self) -> bool: ...
|
||||
def decompress(self, value: Any) -> Optional[Any]: ...
|
||||
media: Any = ...
|
||||
|
||||
class SplitDateTimeWidget(MultiWidget):
|
||||
supports_microseconds: bool = ...
|
||||
def __init__(
|
||||
self,
|
||||
attrs: Optional[Dict[str, str]] = ...,
|
||||
attrs: Optional[_OptAttrs] = ...,
|
||||
date_format: Optional[str] = ...,
|
||||
time_format: Optional[str] = ...,
|
||||
date_attrs: Optional[Dict[str, str]] = ...,
|
||||
time_attrs: Optional[Dict[str, str]] = ...,
|
||||
) -> None: ...
|
||||
|
||||
class SplitHiddenDateTimeWidget(SplitDateTimeWidget):
|
||||
def __init__(
|
||||
self,
|
||||
attrs: Optional[Dict[str, str]] = ...,
|
||||
date_format: None = ...,
|
||||
time_format: None = ...,
|
||||
date_attrs: Optional[Dict[str, str]] = ...,
|
||||
time_attrs: Optional[Dict[str, str]] = ...,
|
||||
) -> None: ...
|
||||
class SplitHiddenDateTimeWidget(SplitDateTimeWidget): ...
|
||||
|
||||
class SelectDateWidget(Widget):
|
||||
none_value: Any = ...
|
||||
|
||||
Reference in New Issue
Block a user