mirror of
https://github.com/davidhalter/django-stubs.git
synced 2026-05-25 01:38:40 +08:00
enable some test folders, bunch of fixes
This commit is contained in:
@@ -24,7 +24,7 @@ class DummyNode(Node):
|
||||
parents: Set[Any]
|
||||
origin: Any = ...
|
||||
error_message: Any = ...
|
||||
def __init__(self, key: Tuple[str, str], origin: Migration, error_message: str) -> None: ...
|
||||
def __init__(self, key: Tuple[str, str], origin: Union[Migration, str], error_message: str) -> None: ...
|
||||
__class__: Any = ...
|
||||
def promote(self) -> None: ...
|
||||
def raise_error(self) -> None: ...
|
||||
@@ -35,7 +35,7 @@ class MigrationGraph:
|
||||
cached: bool = ...
|
||||
def __init__(self) -> None: ...
|
||||
def add_node(self, key: Tuple[str, str], migration: Optional[Migration]) -> None: ...
|
||||
def add_dummy_node(self, key: Tuple[str, str], origin: Migration, error_message: str) -> None: ...
|
||||
def add_dummy_node(self, key: Tuple[str, str], origin: Union[Migration, str], error_message: str) -> None: ...
|
||||
def add_dependency(
|
||||
self,
|
||||
migration: Optional[Union[Migration, str]],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union
|
||||
from typing import Any, Collection, Dict, List, Optional, Sequence, Tuple, Union
|
||||
|
||||
from django.db.migrations.operations.base import Operation
|
||||
from django.db.models.indexes import Index
|
||||
@@ -13,17 +13,17 @@ class ModelOperation(Operation):
|
||||
|
||||
class CreateModel(ModelOperation):
|
||||
serialization_expand_args: Any = ...
|
||||
fields: Any = ...
|
||||
fields: Sequence[Tuple[str, Field]] = ...
|
||||
options: Any = ...
|
||||
bases: Any = ...
|
||||
managers: Any = ...
|
||||
bases: Optional[Sequence[Union[type, str]]] = ...
|
||||
managers: Optional[Sequence[Tuple[str, Manager]]] = ...
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
fields: List[Tuple[str, Field]],
|
||||
fields: Sequence[Tuple[str, Field]],
|
||||
options: Optional[Dict[str, Any]] = ...,
|
||||
bases: Optional[Union[Tuple[Type[Any], ...], Tuple[str, ...]]] = ...,
|
||||
managers: Optional[List[Tuple[str, Manager]]] = ...,
|
||||
bases: Optional[Sequence[Union[type, str]]] = ...,
|
||||
managers: Optional[Sequence[Tuple[str, Manager]]] = ...,
|
||||
) -> None: ...
|
||||
def model_to_key(self, model: str) -> List[str]: ...
|
||||
|
||||
@@ -45,13 +45,13 @@ class FieldRelatedOptionOperation(ModelOptionOperation): ...
|
||||
|
||||
class AlterUniqueTogether(FieldRelatedOptionOperation):
|
||||
option_name: str = ...
|
||||
unique_together: Any = ...
|
||||
def __init__(self, name: str, unique_together: Set[Tuple[str, ...]]) -> None: ...
|
||||
unique_together: Collection[Sequence[str]] = ...
|
||||
def __init__(self, name: str, unique_together: Collection[Sequence[str]]) -> None: ...
|
||||
|
||||
class AlterIndexTogether(FieldRelatedOptionOperation):
|
||||
option_name: str = ...
|
||||
index_together: Set[Tuple[str, ...]] = ...
|
||||
def __init__(self, name: str, index_together: Set[Tuple[str, ...]]) -> None: ...
|
||||
index_together: Collection[Sequence[str]] = ...
|
||||
def __init__(self, name: str, index_together: Collection[Sequence[str]]) -> None: ...
|
||||
|
||||
class AlterOrderWithRespectTo(FieldRelatedOptionOperation):
|
||||
order_with_respect_to: str = ...
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
from typing import Any, Callable, List, Optional
|
||||
from typing import Any, Callable, Optional, Sequence, Dict
|
||||
|
||||
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
|
||||
from django.db.migrations.operations.models import CreateModel
|
||||
from django.db.migrations.state import ProjectState, StateApps
|
||||
from django.db.migrations.state import StateApps
|
||||
|
||||
from .base import Operation
|
||||
|
||||
class SeparateDatabaseAndState(Operation):
|
||||
serialization_expand_args: Any = ...
|
||||
database_operations: Any = ...
|
||||
state_operations: Any = ...
|
||||
def __init__(self, database_operations: List[Any] = ..., state_operations: List[CreateModel] = ...) -> None: ...
|
||||
database_operations: Sequence[Operation] = ...
|
||||
state_operations: Sequence[Operation] = ...
|
||||
def __init__(
|
||||
self, database_operations: Sequence[Operation] = ..., state_operations: Sequence[Operation] = ...
|
||||
) -> None: ...
|
||||
|
||||
class RunSQL(Operation):
|
||||
noop: str = ...
|
||||
@@ -30,17 +31,17 @@ class RunSQL(Operation):
|
||||
|
||||
class RunPython(Operation):
|
||||
reduces_to_sql: bool = ...
|
||||
atomic: Any = ...
|
||||
code: Any = ...
|
||||
reverse_code: Any = ...
|
||||
hints: Any = ...
|
||||
elidable: Any = ...
|
||||
atomic: bool = ...
|
||||
code: Callable = ...
|
||||
reverse_code: Optional[Callable] = ...
|
||||
hints: Optional[Dict[str, Any]] = ...
|
||||
elidable: bool = ...
|
||||
def __init__(
|
||||
self,
|
||||
code: Callable,
|
||||
reverse_code: Optional[Callable] = ...,
|
||||
atomic: Optional[bool] = ...,
|
||||
hints: None = ...,
|
||||
hints: Optional[Dict[str, Any]] = ...,
|
||||
elidable: bool = ...,
|
||||
) -> None: ...
|
||||
@staticmethod
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Dict, Iterator, List, Optional, Tuple, Type, DefaultDict
|
||||
from typing import Any, Dict, Iterator, List, Optional, Tuple, Type, DefaultDict, Union, Sequence
|
||||
|
||||
from django.apps.registry import Apps
|
||||
from django.db.models.base import Model
|
||||
@@ -31,7 +31,7 @@ class ModelState:
|
||||
name: str,
|
||||
fields: List[Tuple[str, Field]],
|
||||
options: Optional[Dict[str, Any]] = ...,
|
||||
bases: Optional[Tuple[Type[Model]]] = ...,
|
||||
bases: Optional[Sequence[Union[Type[Model], str]]] = ...,
|
||||
managers: Optional[List[Tuple[str, Manager]]] = ...,
|
||||
) -> None: ...
|
||||
def clone(self) -> ModelState: ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Optional, Set, Tuple, Type, List
|
||||
from typing import Any, Optional, Set, Tuple, Type, List, Union
|
||||
|
||||
from django.db.migrations.migration import Migration
|
||||
from django.db.migrations.operations.base import Operation
|
||||
@@ -24,7 +24,7 @@ class OperationWriter:
|
||||
class MigrationWriter:
|
||||
migration: Migration = ...
|
||||
needs_manual_porting: bool = ...
|
||||
def __init__(self, migration: Migration) -> None: ...
|
||||
def __init__(self, migration: Union[type, Migration]) -> None: ...
|
||||
def as_string(self) -> str: ...
|
||||
@property
|
||||
def basedir(self) -> str: ...
|
||||
|
||||
@@ -39,7 +39,6 @@ from .fields import (
|
||||
BinaryField as BinaryField,
|
||||
DurationField as DurationField,
|
||||
BigAutoField as BigAutoField,
|
||||
FileField as FileField,
|
||||
CommaSeparatedIntegerField as CommaSeparatedIntegerField,
|
||||
)
|
||||
|
||||
@@ -53,7 +52,12 @@ from .fields.related import (
|
||||
OneToOneRel as OneToOneRel,
|
||||
ForeignObjectRel as ForeignObjectRel,
|
||||
)
|
||||
from .fields.files import ImageField as ImageField, FileField as FileField
|
||||
from .fields.files import (
|
||||
ImageField as ImageField,
|
||||
FileField as FileField,
|
||||
FieldFile as FieldFile,
|
||||
FileDescriptor as FileDescriptor,
|
||||
)
|
||||
from .fields.proxy import OrderWrt as OrderWrt
|
||||
|
||||
from .deletion import (
|
||||
|
||||
@@ -10,3 +10,4 @@ def PROTECT(collector, field, sub_objs, using): ...
|
||||
def SET(value: Any) -> Callable: ...
|
||||
|
||||
class ProtectedError(IntegrityError): ...
|
||||
class Collector: ...
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import uuid
|
||||
from datetime import date, time, datetime, timedelta
|
||||
from typing import Any, Optional, Tuple, Iterable, Callable, Dict, Union, Type
|
||||
import decimal
|
||||
|
||||
from django.core.files.storage import Storage
|
||||
from django.db.models import Model
|
||||
from django.db.models.query_utils import RegisterLookupMixin
|
||||
|
||||
@@ -10,7 +11,7 @@ from django.core.exceptions import FieldDoesNotExist as FieldDoesNotExist
|
||||
from django.forms import Widget, Field as FormField
|
||||
from .mixins import NOT_PROVIDED as NOT_PROVIDED
|
||||
|
||||
_Choice = Tuple[Any, str]
|
||||
_Choice = Tuple[Any, Any]
|
||||
_ChoiceNamedGroup = Union[Tuple[str, Iterable[_Choice]], Tuple[str, Any]]
|
||||
_FieldChoices = Iterable[Union[_Choice, _ChoiceNamedGroup]]
|
||||
|
||||
@@ -58,6 +59,7 @@ class Field(RegisterLookupMixin):
|
||||
def get_internal_type(self) -> str: ...
|
||||
def formfield(self, **kwargs) -> FormField: ...
|
||||
def contribute_to_class(self, cls: Type[Model], name: str, private_only: bool = ...) -> None: ...
|
||||
def to_python(self, value: Any) -> Any: ...
|
||||
|
||||
class IntegerField(Field):
|
||||
def __set__(self, instance, value: Union[int, F]) -> None: ...
|
||||
@@ -70,7 +72,9 @@ class PositiveIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField): ...
|
||||
class PositiveSmallIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField): ...
|
||||
class SmallIntegerField(IntegerField): ...
|
||||
class BigIntegerField(IntegerField): ...
|
||||
class FloatField(Field): ...
|
||||
|
||||
class FloatField(Field):
|
||||
def __get__(self, instance, owner) -> float: ...
|
||||
|
||||
class DecimalField(Field):
|
||||
def __init__(
|
||||
@@ -170,35 +174,8 @@ class NullBooleanField(Field):
|
||||
def __set__(self, instance, value: Optional[bool]) -> None: ...
|
||||
def __get__(self, instance, owner) -> Optional[bool]: ...
|
||||
|
||||
class FileField(Field):
|
||||
def __init__(
|
||||
self,
|
||||
verbose_name: Optional[Union[str, bytes]] = ...,
|
||||
name: Optional[str] = ...,
|
||||
upload_to: str = ...,
|
||||
storage: Optional[Storage] = ...,
|
||||
primary_key: bool = ...,
|
||||
max_length: Optional[int] = ...,
|
||||
unique: bool = ...,
|
||||
blank: bool = ...,
|
||||
null: bool = ...,
|
||||
db_index: bool = ...,
|
||||
default: Any = ...,
|
||||
editable: bool = ...,
|
||||
auto_created: bool = ...,
|
||||
serialize: bool = ...,
|
||||
unique_for_date: Optional[str] = ...,
|
||||
unique_for_month: Optional[str] = ...,
|
||||
unique_for_year: Optional[str] = ...,
|
||||
choices: Optional[_FieldChoices] = ...,
|
||||
help_text: str = ...,
|
||||
db_column: Optional[str] = ...,
|
||||
db_tablespace: Optional[str] = ...,
|
||||
validators: Iterable[_ValidatorCallable] = ...,
|
||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||
): ...
|
||||
|
||||
class IPAddressField(Field): ...
|
||||
class IPAddressField(Field):
|
||||
def __get__(self, instance, owner) -> str: ...
|
||||
|
||||
class GenericIPAddressField(Field):
|
||||
default_error_messages: Any = ...
|
||||
@@ -226,6 +203,7 @@ class GenericIPAddressField(Field):
|
||||
validators: Iterable[_ValidatorCallable] = ...,
|
||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||
) -> None: ...
|
||||
def __get__(self, instance, owner) -> str: ...
|
||||
|
||||
class DateTimeCheckMixin: ...
|
||||
|
||||
@@ -253,6 +231,7 @@ class DateField(DateTimeCheckMixin, Field):
|
||||
validators: Iterable[_ValidatorCallable] = ...,
|
||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||
): ...
|
||||
def __get__(self, instance, owner) -> date: ...
|
||||
|
||||
class TimeField(DateTimeCheckMixin, Field):
|
||||
def __init__(
|
||||
@@ -277,9 +256,13 @@ class TimeField(DateTimeCheckMixin, Field):
|
||||
validators: Iterable[_ValidatorCallable] = ...,
|
||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||
): ...
|
||||
def __get__(self, instance, owner) -> time: ...
|
||||
|
||||
class DateTimeField(DateField): ...
|
||||
class UUIDField(Field): ...
|
||||
class DateTimeField(DateField):
|
||||
def __get__(self, instance, owner) -> datetime: ...
|
||||
|
||||
class UUIDField(Field):
|
||||
def __get__(self, instance, owner) -> uuid.UUID: ...
|
||||
|
||||
class FilePathField(Field):
|
||||
path: str = ...
|
||||
@@ -315,6 +298,9 @@ class FilePathField(Field):
|
||||
): ...
|
||||
|
||||
class BinaryField(Field): ...
|
||||
class DurationField(Field): ...
|
||||
|
||||
class DurationField(Field):
|
||||
def __get__(self, instance, owner) -> timedelta: ...
|
||||
|
||||
class BigAutoField(AutoField): ...
|
||||
class CommaSeparatedIntegerField(CharField): ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Callable, List, Optional, Type, Union, Tuple
|
||||
from typing import Any, Callable, List, Optional, Type, Union, Tuple, Iterable
|
||||
|
||||
from django.core.checks.messages import Error
|
||||
from django.core.files.base import File
|
||||
@@ -6,7 +6,7 @@ from django.core.files.images import ImageFile
|
||||
from django.core.files.storage import FileSystemStorage, Storage
|
||||
from django.db.models.base import Model
|
||||
|
||||
from django.db.models.fields import Field
|
||||
from django.db.models.fields import Field, _FieldChoices, _ValidatorCallable, _ErrorMessagesToOverride
|
||||
from django.forms import fields as form_fields
|
||||
|
||||
BLANK_CHOICE_DASH: List[Tuple[str, str]] = ...
|
||||
@@ -31,31 +31,39 @@ class FieldFile(File):
|
||||
class FileDescriptor:
|
||||
field: FileField = ...
|
||||
def __init__(self, field: FileField) -> None: ...
|
||||
def __get__(self, instance: Optional[Model], cls: Type[Model] = ...) -> Union[FieldFile, FileDescriptor]: ...
|
||||
def __set__(self, instance: Model, value: Optional[Any]) -> None: ...
|
||||
def __get__(self, instance: Optional[Model], cls: Type[Model] = ...) -> Union[FieldFile, FileDescriptor]: ...
|
||||
|
||||
class FileField(Field):
|
||||
attr_class: Any = ...
|
||||
descriptor_class: Any = ...
|
||||
description: Any = ...
|
||||
storage: Any = ...
|
||||
upload_to: Any = ...
|
||||
upload_to: Union[str, Callable] = ...
|
||||
def __init__(
|
||||
self,
|
||||
verbose_name: Optional[str] = ...,
|
||||
verbose_name: Optional[Union[str, bytes]] = ...,
|
||||
name: Optional[str] = ...,
|
||||
upload_to: Union[Callable, str] = ...,
|
||||
upload_to: Union[str, Callable] = ...,
|
||||
storage: Optional[Storage] = ...,
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
def check(self, **kwargs: Any) -> List[Error]: ...
|
||||
def deconstruct(self) -> Any: ...
|
||||
def get_internal_type(self) -> str: ...
|
||||
def get_prep_value(self, value: Union[FieldFile, str]) -> str: ...
|
||||
def pre_save(self, model_instance: Model, add: bool) -> FieldFile: ...
|
||||
primary_key: bool = ...,
|
||||
max_length: Optional[int] = ...,
|
||||
unique: bool = ...,
|
||||
blank: bool = ...,
|
||||
null: bool = ...,
|
||||
db_index: bool = ...,
|
||||
default: Any = ...,
|
||||
editable: bool = ...,
|
||||
auto_created: bool = ...,
|
||||
serialize: bool = ...,
|
||||
unique_for_date: Optional[str] = ...,
|
||||
unique_for_month: Optional[str] = ...,
|
||||
unique_for_year: Optional[str] = ...,
|
||||
choices: Optional[_FieldChoices] = ...,
|
||||
help_text: str = ...,
|
||||
db_column: Optional[str] = ...,
|
||||
db_tablespace: Optional[str] = ...,
|
||||
validators: Iterable[_ValidatorCallable] = ...,
|
||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||
): ...
|
||||
def generate_filename(self, instance: Optional[Model], filename: str) -> str: ...
|
||||
def save_form_data(self, instance: Model, data: Optional[Union[bool, File, str]]) -> None: ...
|
||||
def formfield(self, **kwargs: Any) -> form_fields.FileField: ...
|
||||
|
||||
class ImageFileDescriptor(FileDescriptor):
|
||||
field: ImageField
|
||||
@@ -74,7 +82,4 @@ class ImageField(FileField):
|
||||
height_field: Optional[str] = ...,
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
def check(self, **kwargs: Any) -> List[Any]: ...
|
||||
def deconstruct(self) -> Any: ...
|
||||
def update_dimension_fields(self, instance: Model, force: bool = ..., *args: Any, **kwargs: Any) -> None: ...
|
||||
def formfield(self, **kwargs: Any) -> form_fields.ImageField: ...
|
||||
|
||||
@@ -81,7 +81,7 @@ class ForeignObject(RelatedField):
|
||||
rel: None = ...,
|
||||
related_name: Optional[str] = ...,
|
||||
related_query_name: None = ...,
|
||||
limit_choices_to: None = ...,
|
||||
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
|
||||
parent_link: bool = ...,
|
||||
swappable: bool = ...,
|
||||
verbose_name: Optional[str] = ...,
|
||||
@@ -126,7 +126,7 @@ class ManyToManyField(RelatedField, Generic[_T]):
|
||||
to: Union[Type[_T], str],
|
||||
related_name: Optional[str] = ...,
|
||||
related_query_name: Optional[str] = ...,
|
||||
limit_choices_to: Optional[Dict[str, Any]] = ...,
|
||||
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
|
||||
symmetrical: Optional[bool] = ...,
|
||||
through: Optional[Union[str, Type[Model]]] = ...,
|
||||
through_fields: Optional[Tuple[str, str]] = ...,
|
||||
|
||||
@@ -26,7 +26,7 @@ class ForeignObjectRel(FieldCacheMixin):
|
||||
model: Union[Type[Model], str] = ...
|
||||
related_name: Optional[str] = ...
|
||||
related_query_name: Optional[str] = ...
|
||||
limit_choices_to: Union[Callable, Dict[str, Any]] = ...
|
||||
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...
|
||||
parent_link: bool = ...
|
||||
on_delete: Callable = ...
|
||||
symmetrical: bool = ...
|
||||
@@ -38,7 +38,7 @@ class ForeignObjectRel(FieldCacheMixin):
|
||||
to: Union[Type[Model], str],
|
||||
related_name: Optional[str] = ...,
|
||||
related_query_name: Optional[str] = ...,
|
||||
limit_choices_to: Any = ...,
|
||||
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
|
||||
parent_link: bool = ...,
|
||||
on_delete: Optional[Callable] = ...,
|
||||
) -> None: ...
|
||||
@@ -86,7 +86,7 @@ class ManyToOneRel(ForeignObjectRel):
|
||||
field_name: Optional[str],
|
||||
related_name: Optional[str] = ...,
|
||||
related_query_name: Optional[str] = ...,
|
||||
limit_choices_to: Optional[Union[Callable, Dict[str, Union[int, str]], Q]] = ...,
|
||||
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
|
||||
parent_link: bool = ...,
|
||||
on_delete: Callable = ...,
|
||||
) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user