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

Add a lot of runtime defaults to stubs with stubdefaulter #2327

Merged
merged 7 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 4 additions & 2 deletions django-stubs/apps/config.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ class AppConfig:
def __init__(self, app_name: str, app_module: types.ModuleType | None) -> None: ...
@classmethod
def create(cls, entry: str) -> AppConfig: ...
def get_model(self, model_name: str, require_ready: bool = ...) -> type[Model]: ...
def get_models(self, include_auto_created: bool = ..., include_swapped: bool = ...) -> Iterator[type[Model]]: ...
def get_model(self, model_name: str, require_ready: bool = True) -> type[Model]: ...
def get_models(
self, include_auto_created: bool = False, include_swapped: bool = False
) -> Iterator[type[Model]]: ...
def import_models(self) -> None: ...
def ready(self) -> None: ...
8 changes: 4 additions & 4 deletions django-stubs/apps/registry.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ class Apps:
_pending_operations: dict[tuple[str, str], list]
models_ready: bool
ready: bool
def __init__(self, installed_apps: Iterable[AppConfig | str] | None = ...) -> None: ...
def populate(self, installed_apps: Iterable[AppConfig | str] | None = ...) -> None: ...
def __init__(self, installed_apps: Iterable[AppConfig | str] | None = ()) -> None: ...
def populate(self, installed_apps: Iterable[AppConfig | str] | None = None) -> None: ...
def check_apps_ready(self) -> None: ...
def check_models_ready(self) -> None: ...
def get_app_configs(self) -> Iterable[AppConfig]: ...
def get_app_config(self, app_label: str) -> AppConfig: ...
# it's not possible to support it in plugin properly now
def get_models(self, include_auto_created: bool = ..., include_swapped: bool = ...) -> list[type[Model]]: ...
def get_model(self, app_label: str, model_name: str | None = ..., require_ready: bool = ...) -> type[Any]: ...
def get_models(self, include_auto_created: bool = False, include_swapped: bool = False) -> list[type[Model]]: ...
def get_model(self, app_label: str, model_name: str | None = None, require_ready: bool = True) -> type[Any]: ...
def register_model(self, app_label: str, model: type[Model]) -> None: ...
def is_installed(self, app_name: str) -> bool: ...
def get_containing_app_config(self, object_name: str) -> AppConfig | None: ...
Expand Down
4 changes: 2 additions & 2 deletions django-stubs/contrib/contenttypes/checks.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ from django.apps.config import AppConfig
from django.core.checks.messages import CheckMessage

def check_generic_foreign_keys(
app_configs: Sequence[AppConfig] | None = ..., **kwargs: Any
app_configs: Sequence[AppConfig] | None = None, **kwargs: Any
) -> Sequence[CheckMessage]: ...
def check_model_name_lengths(
app_configs: Sequence[AppConfig] | None = ..., **kwargs: Any
app_configs: Sequence[AppConfig] | None = None, **kwargs: Any
) -> Sequence[CheckMessage]: ...
8 changes: 4 additions & 4 deletions django-stubs/contrib/contenttypes/management/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ class RenameContentType(migrations.RunPython):
def rename_backward(self, apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: ...

def inject_rename_contenttypes_operations(
plan: list[tuple[Migration, bool]] | None = ..., apps: StateApps = ..., using: str = ..., **kwargs: Any
plan: list[tuple[Migration, bool]] | None = None, apps: StateApps = ..., using: str = "default", **kwargs: Any
) -> None: ...
def get_contenttypes_and_models(
app_config: AppConfig, using: str, ContentType: type[ContentType]
) -> tuple[dict[str, ContentType], dict[str, type[Model]]]: ...
def create_contenttypes(
app_config: AppConfig,
verbosity: int = ...,
interactive: bool = ...,
using: str = ...,
verbosity: int = 2,
interactive: bool = True,
using: str = "default",
apps: Apps = ...,
**kwargs: Any,
) -> None: ...
2 changes: 1 addition & 1 deletion django-stubs/contrib/contenttypes/prefetch.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ from django.db.models import Prefetch
from django.db.models.query import QuerySet

class GenericPrefetch(Prefetch):
def __init__(self, lookup: str, querysets: list[QuerySet], to_attr: str | None = ...) -> None: ...
def __init__(self, lookup: str, querysets: list[QuerySet], to_attr: str | None = None) -> None: ...
def __getstate__(self) -> dict[str, Any]: ...
def get_current_querysets(self, level: int) -> list[QuerySet] | None: ...
2 changes: 1 addition & 1 deletion django-stubs/contrib/gis/db/backends/spatialite/schema.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SpatialiteSchemaEditor(DatabaseSchemaEditor):
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def geo_quote_name(self, name: Any) -> Any: ...
def column_sql(
self, model: type[Model], field: Field, include_default: bool = ...
self, model: type[Model], field: Field, include_default: bool = False
) -> tuple[None, None] | tuple[str, list[Any]]: ...
def remove_geometry_metadata(self, model: type[Model], field: Field) -> None: ...
def create_model(self, model: type[Model]) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/contrib/gis/db/backends/utils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SpatialOperator:
sql_template: Any
op: Any
func: Any
def __init__(self, op: Any | None = ..., func: Any | None = ...) -> None: ...
def __init__(self, op: Any | None = None, func: Any | None = None) -> None: ...
@property
def default_template(self) -> Any: ...
def as_sql(
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/contrib/gis/measure.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class MeasureBase:
UNITS: dict[str, float]
ALIAS: dict[str, str]
LALIAS: dict[str, str]
def __init__(self, default_unit: str | None = ..., **kwargs: Any) -> None: ...
def __init__(self, default_unit: str | None = None, **kwargs: Any) -> None: ...
standard: Any
def __getattr__(self, name: str) -> float: ...
def __eq__(self, other: object) -> bool: ...
Expand Down
4 changes: 2 additions & 2 deletions django-stubs/contrib/humanize/templatetags/humanize.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ from django import template
register: template.Library

def ordinal(value: str | SupportsInt | None) -> str | None: ...
def intcomma(value: str | SupportsInt | None, use_l10n: bool = ...) -> str: ...
def intcomma(value: str | SupportsInt | None, use_l10n: bool = True) -> str: ...

intword_converters: tuple[tuple[int, Callable]]

def intword(value: str | SupportsInt | None) -> int | str | None: ...
def apnumber(value: str | SupportsInt | None) -> int | str | None: ...
def naturalday(value: date | str | None, arg: str | None = ...) -> str | None: ...
def naturalday(value: date | str | None, arg: str | None = None) -> str | None: ...
def naturaltime(value: datetime) -> str: ...

class NaturalTimeFormatter:
Expand Down
24 changes: 12 additions & 12 deletions django-stubs/contrib/messages/api.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,39 @@ def add_message(
request: HttpRequest | None,
level: int,
message: _StrOrPromise,
extra_tags: str = ...,
fail_silently: bool | str = ...,
extra_tags: str = "",
fail_silently: bool | str = False,
) -> None: ...
def get_messages(request: HttpRequest) -> list[Any] | BaseStorage: ...
def get_level(request: HttpRequest) -> int: ...
def set_level(request: HttpRequest, level: int) -> bool: ...
def debug(
request: HttpRequest,
message: _StrOrPromise,
extra_tags: str = ...,
fail_silently: bool | str = ...,
extra_tags: str = "",
fail_silently: bool | str = False,
) -> None: ...
def info(
request: HttpRequest,
message: _StrOrPromise,
extra_tags: str = ...,
fail_silently: bool | str = ...,
extra_tags: str = "",
fail_silently: bool | str = False,
) -> None: ...
def success(
request: HttpRequest,
message: _StrOrPromise,
extra_tags: str = ...,
fail_silently: bool | str = ...,
extra_tags: str = "",
fail_silently: bool | str = False,
) -> None: ...
def warning(
request: HttpRequest,
message: _StrOrPromise,
extra_tags: str = ...,
fail_silently: bool | str = ...,
extra_tags: str = "",
fail_silently: bool | str = False,
) -> None: ...
def error(
request: HttpRequest,
message: _StrOrPromise,
extra_tags: str = ...,
fail_silently: bool | str = ...,
extra_tags: str = "",
fail_silently: bool | str = False,
) -> None: ...
4 changes: 2 additions & 2 deletions django-stubs/contrib/messages/storage/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Message:
level: int
message: str
extra_tags: str
def __init__(self, level: int, message: str, extra_tags: str | None = ...) -> None: ...
def __init__(self, level: int, message: str, extra_tags: str | None = None) -> None: ...
@property
def tags(self) -> str: ...
@property
Expand All @@ -25,5 +25,5 @@ class BaseStorage:
def __iter__(self) -> Iterator[Message]: ...
def __contains__(self, item: Any) -> bool: ...
def update(self, response: HttpResponseBase) -> list[Message] | None: ...
def add(self, level: int, message: str, extra_tags: str | None = ...) -> None: ...
def add(self, level: int, message: str, extra_tags: str | None = "") -> None: ...
level: Any
2 changes: 1 addition & 1 deletion django-stubs/contrib/messages/test.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ from django.http.response import HttpResponse

class MessagesTestMixin:
def assertMessages(
self, response: HttpResponse, expected_messages: list[Any] | BaseStorage, *, ordered: bool = ...
self, response: HttpResponse, expected_messages: list[Any] | BaseStorage, *, ordered: bool = True
) -> None: ...
14 changes: 7 additions & 7 deletions django-stubs/contrib/postgres/constraints.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ class ExclusionConstraint(BaseConstraint):
*,
name: str,
expressions: Sequence[tuple[str | Combinable, str]],
index_type: str | None = ...,
condition: Q | None = ...,
deferrable: Deferrable | None = ...,
include: list[str] | tuple[str] | None = ...,
violation_error_code: str | None = ...,
violation_error_message: _StrOrPromise | None = ...,
index_type: str | None = None,
condition: Q | None = None,
deferrable: Deferrable | None = None,
include: list[str] | tuple[str] | None = None,
violation_error_code: str | None = None,
violation_error_message: _StrOrPromise | None = None,
) -> None: ...
def check_supported(self, schema_editor: BaseDatabaseSchemaEditor) -> None: ...
def validate(
self, model: type[Model], instance: Model, exclude: Iterable[str] | None = ..., using: str = ...
self, model: type[Model], instance: Model, exclude: Iterable[str] | None = None, using: str = "default"
) -> None: ...
2 changes: 1 addition & 1 deletion django-stubs/contrib/postgres/fields/array.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ArrayField(CheckFieldDefaultMixin, Field[_ST, _GT]):
def __init__(
self,
base_field: Field,
size: int | None = ...,
size: int | None = None,
*,
verbose_name: _StrOrPromise | None = ...,
name: str | None = ...,
Expand Down
10 changes: 5 additions & 5 deletions django-stubs/contrib/postgres/forms/array.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class SimpleArrayField(forms.CharField):
self,
base_field: forms.Field,
*,
delimiter: str = ...,
max_length: int | None = ...,
min_length: int | None = ...,
delimiter: str = ",",
max_length: int | None = None,
min_length: int | None = None,
**kwargs: Any,
) -> None: ...
def clean(self, value: Any) -> Sequence[Any]: ...
Expand All @@ -41,7 +41,7 @@ class SplitArrayWidget(forms.Widget):
def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> Any: ...
def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ...
def id_for_label(self, id_: str) -> str: ...
def get_context(self, name: str, value: Any, attrs: _OptAttrs | None = ...) -> dict[str, Any]: ...
def get_context(self, name: str, value: Any, attrs: _OptAttrs | None = None) -> dict[str, Any]: ...
@property
def needs_multipart_form(self) -> bool: ... # type: ignore[override]

Expand All @@ -51,7 +51,7 @@ class SplitArrayField(forms.Field):
size: int
remove_trailing_nulls: bool
def __init__(
self, base_field: forms.Field, size: int, *, remove_trailing_nulls: bool = ..., **kwargs: Any
self, base_field: forms.Field, size: int, *, remove_trailing_nulls: bool = False, **kwargs: Any
) -> None: ...
def to_python(self, value: Any) -> Sequence[Any]: ...
def clean(self, value: Any) -> Sequence[Any]: ...
Expand Down
4 changes: 2 additions & 2 deletions django-stubs/contrib/postgres/forms/ranges.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ from django.forms.widgets import MultiWidget, _OptAttrs
from psycopg2.extras import Range # type: ignore [import-untyped]

class RangeWidget(MultiWidget):
def __init__(self, base_widget: forms.Widget | type[forms.Widget], attrs: _OptAttrs | None = ...) -> None: ...
def __init__(self, base_widget: forms.Widget | type[forms.Widget], attrs: _OptAttrs | None = None) -> None: ...
def decompress(self, value: Any) -> tuple[Any | None, Any | None]: ...

class HiddenRangeWidget(RangeWidget):
def __init__(self, attrs: _OptAttrs | None = ...) -> None: ...
def __init__(self, attrs: _OptAttrs | None = None) -> None: ...

class BaseRangeField(forms.MultiValueField):
default_error_messages: _ErrorMessagesDict
Expand Down
24 changes: 12 additions & 12 deletions django-stubs/contrib/postgres/indexes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PostgresIndex(Index):
@cached_property
def max_name_length(self) -> int: ... # type: ignore[override]
def create_sql(
self, model: type[Model], schema_editor: BaseDatabaseSchemaEditor, using: str = ..., **kwargs: Any
self, model: type[Model], schema_editor: BaseDatabaseSchemaEditor, using: str = "", **kwargs: Any
) -> Statement: ...
def check_supported(self, schema_editor: BaseDatabaseSchemaEditor) -> None: ...
def get_with_params(self) -> Sequence[str]: ...
Expand All @@ -22,8 +22,8 @@ class BloomIndex(PostgresIndex):
def __init__(
self,
*expressions: BaseExpression | Combinable | str,
length: int | None = ...,
columns: _ListOrTuple[int] = ...,
length: int | None = None,
columns: _ListOrTuple[int] = (),
fields: Sequence[str] = ...,
name: str | None = ...,
db_tablespace: str | None = ...,
Expand All @@ -36,8 +36,8 @@ class BrinIndex(PostgresIndex):
def __init__(
self,
*expressions: BaseExpression | Combinable | str,
autosummarize: bool | None = ...,
pages_per_range: int | None = ...,
autosummarize: bool | None = None,
pages_per_range: int | None = None,
fields: Sequence[str] = ...,
name: str | None = ...,
db_tablespace: str | None = ...,
Expand All @@ -50,7 +50,7 @@ class BTreeIndex(PostgresIndex):
def __init__(
self,
*expressions: BaseExpression | Combinable | str,
fillfactor: int | None = ...,
fillfactor: int | None = None,
fields: Sequence[str] = ...,
name: str | None = ...,
db_tablespace: str | None = ...,
Expand All @@ -63,8 +63,8 @@ class GinIndex(PostgresIndex):
def __init__(
self,
*expressions: BaseExpression | Combinable | str,
fastupdate: bool | None = ...,
gin_pending_list_limit: int | None = ...,
fastupdate: bool | None = None,
gin_pending_list_limit: int | None = None,
fields: Sequence[str] = ...,
name: str | None = ...,
db_tablespace: str | None = ...,
Expand All @@ -77,8 +77,8 @@ class GistIndex(PostgresIndex):
def __init__(
self,
*expressions: BaseExpression | Combinable | str,
buffering: bool | None = ...,
fillfactor: int | None = ...,
buffering: bool | None = None,
fillfactor: int | None = None,
fields: Sequence[str] = ...,
name: str | None = ...,
db_tablespace: str | None = ...,
Expand All @@ -91,7 +91,7 @@ class HashIndex(PostgresIndex):
def __init__(
self,
*expressions: BaseExpression | Combinable | str,
fillfactor: int | None = ...,
fillfactor: int | None = None,
fields: Sequence[str] = ...,
name: str | None = ...,
db_tablespace: str | None = ...,
Expand All @@ -104,7 +104,7 @@ class SpGistIndex(PostgresIndex):
def __init__(
self,
*expressions: BaseExpression | Combinable | str,
fillfactor: int | None = ...,
fillfactor: int | None = None,
fields: Sequence[str] = ...,
name: str | None = ...,
db_tablespace: str | None = ...,
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/contrib/postgres/operations.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CollationOperation(Operation):
locale: str
provider: str
deterministic: bool
def __init__(self, name: str, locale: str, *, provider: str = ..., deterministic: bool = ...) -> None: ...
def __init__(self, name: str, locale: str, *, provider: str = "libc", deterministic: bool = True) -> None: ...
def create_collation(self, schema_editor: BaseDatabaseSchemaEditor) -> None: ...
def remove_collation(self, schema_editor: BaseDatabaseSchemaEditor) -> None: ...

Expand Down
Loading
Loading