Skip to content

Commit

Permalink
This PR adds some defaults to stubs with stubdefaulter (#2326)
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn committed Aug 7, 2024
1 parent b0fefea commit e78d129
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions django-stubs/contrib/admin/utils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ def label_for_field(
name: Callable | str,
model: type[Model],
model_admin: BaseModelAdmin | None = ...,
return_attr: Literal[True] = ...,
return_attr: Literal[True] = True,
form: BaseForm | None = ...,
) -> tuple[str, Callable | str | None]: ...
@overload
def label_for_field(
name: Callable | str,
model: type[Model],
model_admin: BaseModelAdmin | None = ...,
return_attr: Literal[False] = ...,
return_attr: Literal[False] = False,
form: BaseForm | None = ...,
) -> str: ...
def help_text_for_field(name: str, model: type[Model]) -> str: ...
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/contrib/admin/views/decorators.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ _C = TypeVar("_C", bound=Callable)
def staff_member_required(view_func: _C = ..., redirect_field_name: str | None = ..., login_url: str = ...) -> _C: ...
@overload
def staff_member_required(
view_func: None = ..., redirect_field_name: str | None = ..., login_url: str = ...
view_func: None = None, redirect_field_name: str | None = ..., login_url: str = ...
) -> Callable: ...
2 changes: 1 addition & 1 deletion django-stubs/contrib/gis/gdal/layer.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Layer(GDALBase):
spatial_filter: OGRGeometry | None
def get_fields(self, field_name: str) -> list[Any]: ...
@overload
def get_geoms(self, geos: Literal[False] = ...) -> list[OGRGeometry]: ...
def get_geoms(self, geos: Literal[False] = False) -> list[OGRGeometry]: ...
@overload
def get_geoms(self, geos: Literal[True]) -> list[GEOSGeometry]: ...
def test_capability(self, capability: AnyStr) -> bool: ...
4 changes: 2 additions & 2 deletions django-stubs/contrib/gis/gdal/raster/band.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class GDALBand(GDALRasterBase):
@nodata_value.setter
def nodata_value(self, value: float | None) -> None: ...
@overload
def datatype(self, as_string: Literal[False] = ...) -> int: ...
def datatype(self, as_string: Literal[False] = False) -> int: ...
@overload
def datatype(self, as_string: Literal[True]) -> str: ...
@overload
def color_interp(self, as_string: Literal[False] = ...) -> int: ...
def color_interp(self, as_string: Literal[False] = False) -> int: ...
@overload
def color_interp(self, as_string: Literal[True]) -> str: ...
def data(
Expand Down
10 changes: 5 additions & 5 deletions django-stubs/contrib/staticfiles/finders.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ searched_locations: Any
class BaseFinder:
def check(self, **kwargs: Any) -> list[CheckMessage]: ...
@overload
def find(self, path: str, all: Literal[False] = ...) -> str | None: ...
def find(self, path: str, all: Literal[False] = False) -> str | None: ...
@overload
def find(self, path: str, all: Literal[True]) -> list[str]: ...
def list(self, ignore_patterns: Iterable[str] | None) -> Iterable[Any]: ...
Expand All @@ -20,7 +20,7 @@ class FileSystemFinder(BaseFinder):
def __init__(self, app_names: Sequence[str] | None = ..., *args: Any, **kwargs: Any) -> None: ...
def find_location(self, root: str, path: str, prefix: str | None = ...) -> str | None: ...
@overload
def find(self, path: str, all: Literal[False] = ...) -> str | None: ...
def find(self, path: str, all: Literal[False] = False) -> str | None: ...
@overload
def find(self, path: str, all: Literal[True]) -> list[str]: ...
def list(self, ignore_patterns: Iterable[str] | None) -> Iterable[Any]: ...
Expand All @@ -33,7 +33,7 @@ class AppDirectoriesFinder(BaseFinder):
def __init__(self, app_names: Iterable[str] | None = ..., *args: Any, **kwargs: Any) -> None: ...
def find_in_app(self, app: str, path: str) -> str | None: ...
@overload
def find(self, path: str, all: Literal[False] = ...) -> str | None: ...
def find(self, path: str, all: Literal[False] = False) -> str | None: ...
@overload
def find(self, path: str, all: Literal[True]) -> list[str]: ...
def list(self, ignore_patterns: Iterable[str] | None) -> Iterable[Any]: ...
Expand All @@ -42,7 +42,7 @@ class BaseStorageFinder(BaseFinder):
storage: Storage
def __init__(self, storage: Storage | None = ..., *args: Any, **kwargs: Any) -> None: ...
@overload
def find(self, path: str, all: Literal[False] = ...) -> str | None: ...
def find(self, path: str, all: Literal[False] = False) -> str | None: ...
@overload
def find(self, path: str, all: Literal[True]) -> list[str]: ...
def list(self, ignore_patterns: Iterable[str] | None) -> Iterable[Any]: ...
Expand All @@ -52,7 +52,7 @@ class DefaultStorageFinder(BaseStorageFinder):
def __init__(self, *args: Any, **kwargs: Any) -> None: ...

@overload
def find(path: str, all: Literal[False] = ...) -> str | None: ...
def find(path: str, all: Literal[False] = False) -> str | None: ...
@overload
def find(path: str, all: Literal[True]) -> list[str]: ...
def get_finders() -> Iterator[BaseFinder]: ...
Expand Down
4 changes: 2 additions & 2 deletions django-stubs/core/mail/message.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ class EmailMessage:
def recipients(self) -> list[str]: ...
def send(self, fail_silently: bool = ...) -> int: ...
@overload
def attach(self, filename: MIMEBase = ..., content: None = ..., mimetype: None = ...) -> None: ...
def attach(self, filename: MIMEBase = ..., content: None = None, mimetype: None = None) -> None: ...
@overload
def attach(self, filename: None = ..., content: _AttachmentContent = ..., mimetype: str = ...) -> None: ...
def attach(self, filename: None = None, content: _AttachmentContent = ..., mimetype: str = ...) -> None: ...
@overload
def attach(self, filename: str = ..., content: _AttachmentContent = ..., mimetype: str | None = ...) -> None: ...
def attach_file(self, path: str, mimetype: str | None = ...) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/db/models/constraints.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class UniqueConstraint(BaseConstraint):
def __init__(
self,
*expressions: str | BaseExpression | Combinable,
fields: None = ...,
fields: None = None,
name: str | None = ...,
condition: Q | None = ...,
deferrable: Deferrable | None = ...,
Expand Down
6 changes: 3 additions & 3 deletions django-stubs/db/models/sql/compiler.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,19 @@ class SQLCompiler:
def has_results(self) -> bool: ...
@overload
def execute_sql(
self, result_type: Literal["cursor"] = ..., chunked_fetch: bool = ..., chunk_size: int = ...
self, result_type: Literal["cursor"] = "cursor", chunked_fetch: bool = ..., chunk_size: int = ...
) -> CursorWrapper: ...
@overload
def execute_sql(
self, result_type: Literal["no results"] | None = ..., chunked_fetch: bool = ..., chunk_size: int = ...
) -> None: ...
@overload
def execute_sql(
self, result_type: Literal["single"] = ..., chunked_fetch: bool = ..., chunk_size: int = ...
self, result_type: Literal["single"] = "single", chunked_fetch: bool = ..., chunk_size: int = ...
) -> Iterable[Sequence[Any]] | None: ...
@overload
def execute_sql(
self, result_type: Literal["multi"] = ..., chunked_fetch: bool = ..., chunk_size: int = ...
self, result_type: Literal["multi"] = "multi", chunked_fetch: bool = ..., chunk_size: int = ...
) -> Iterable[list[Sequence[Any]]] | None: ...
def as_subquery_condition(self, alias: str, columns: list[str], compiler: SQLCompiler) -> _AsSqlType: ...
def explain_query(self) -> Iterator[str]: ...
Expand Down
4 changes: 2 additions & 2 deletions django-stubs/forms/models.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ class ModelMultipleChoiceField(ModelChoiceField[_M]):
def modelform_defines_fields(form_class: type[ModelForm]) -> bool: ...
@overload
def _get_foreign_key(
parent_model: type[Model], model: type[Model], fk_name: str | None = ..., can_fail: Literal[True] = ...
parent_model: type[Model], model: type[Model], fk_name: str | None = ..., can_fail: Literal[True] = True
) -> ForeignKey | None: ...
@overload
def _get_foreign_key(
parent_model: type[Model], model: type[Model], fk_name: str | None = ..., can_fail: Literal[False] = ...
parent_model: type[Model], model: type[Model], fk_name: str | None = ..., can_fail: Literal[False] = False
) -> ForeignKey: ...
2 changes: 1 addition & 1 deletion django-stubs/http/response.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class HttpResponseBase:
@overload
def get(self, header: str, alternate: str) -> str: ...
@overload
def get(self, header: str, alternate: None = ...) -> str | None: ...
def get(self, header: str, alternate: None = None) -> str | None: ...
def set_cookie(
self,
key: str,
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/template/engine.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Engine:
def get_template_loaders(self, template_loaders: Sequence[_Loader]) -> list[Loader]: ...
def find_template_loader(self, loader: _Loader) -> Loader: ...
def find_template(
self, name: str, dirs: None = ..., skip: list[Origin] | None = ...
self, name: str, dirs: None = None, skip: list[Origin] | None = ...
) -> tuple[Template, Origin]: ...
def from_string(self, template_code: str) -> Template: ...
def get_template(self, template_name: str) -> Template: ...
Expand Down
6 changes: 3 additions & 3 deletions django-stubs/template/library.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ class Library:
@overload
def tag(self, name: str, compile_function: _C) -> _C: ...
@overload
def tag(self, name: str | None = ..., compile_function: None = ...) -> Callable[[_C], _C]: ...
def tag(self, name: str | None = ..., compile_function: None = None) -> Callable[[_C], _C]: ...
def tag_function(self, func: _C) -> _C: ...
@overload
def filter(self, name: _C, filter_func: None = ..., **flags: Any) -> _C: ...
def filter(self, name: _C, filter_func: None = None, **flags: Any) -> _C: ...
@overload
def filter(self, name: str | None, filter_func: _C, **flags: Any) -> _C: ...
@overload
def filter(self, name: str | None = ..., filter_func: None = ..., **flags: Any) -> Callable[[_C], _C]: ...
def filter(self, name: str | None = ..., filter_func: None = None, **flags: Any) -> Callable[[_C], _C]: ...
@overload
def simple_tag(self, func: _C) -> _C: ...
@overload
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/test/testcases.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class TransactionTestCase(SimpleTestCase):
msg: str | None = ...,
) -> None: ...
@overload
def assertNumQueries(self, num: int, func: None = ..., *, using: str = ...) -> _AssertNumQueriesContext: ...
def assertNumQueries(self, num: int, func: None = None, *, using: str = ...) -> _AssertNumQueriesContext: ...
@overload
def assertNumQueries(
self, num: int, func: Callable[..., Any], *args: Any, using: str = ..., **kwargs: Any
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/utils/datastructures.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class MultiValueDict(dict[_K, _V]):
def getlist(self, key: _K, default: _Z = ...) -> list[_V] | _Z: ...
def setlist(self, key: _K, list_: list[_V]) -> None: ...
@overload
def setdefault(self: MultiValueDict[_K, _V | None], key: _K, default: None = ...) -> _V | None: ...
def setdefault(self: MultiValueDict[_K, _V | None], key: _K, default: None = None) -> _V | None: ...
@overload
def setdefault(self, key: _K, default: _V) -> _V: ...
def setlistdefault(self, key: _K, default_list: list[_V] | None = ...) -> list[_V]: ...
Expand Down
12 changes: 6 additions & 6 deletions django-stubs/utils/encoding.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def smart_str(s: _S, encoding: str = ..., *, errors: str = ...) -> _S: ...
@overload
def smart_str(s: Any, encoding: str = ..., *, errors: str = ...) -> str: ...
@overload
def smart_str(s: _PT, encoding: str = ..., strings_only: Literal[True] = ..., errors: str = ...) -> _PT: ...
def smart_str(s: _PT, encoding: str = ..., strings_only: Literal[True] = True, errors: str = ...) -> _PT: ...
@overload
def smart_str(s: _S, encoding: str = ..., strings_only: bool = ..., errors: str = ...) -> _S: ...
@overload
Expand All @@ -32,27 +32,27 @@ def force_str(s: _S, encoding: str = ..., *, errors: str = ...) -> _S: ...
@overload
def force_str(s: Any, encoding: str = ..., *, errors: str = ...) -> str: ...
@overload
def force_str(s: _PT, encoding: str = ..., strings_only: Literal[True] = ..., errors: str = ...) -> _PT: ...
def force_str(s: _PT, encoding: str = ..., strings_only: Literal[True] = True, errors: str = ...) -> _PT: ...
@overload
def force_str(s: _S, encoding: str = ..., strings_only: bool = ..., errors: str = ...) -> _S: ...
@overload
def force_str(s: Any, encoding: str = ..., strings_only: bool = ..., errors: str = ...) -> str: ...
@overload
def smart_bytes(s: _P, encoding: str = ..., strings_only: bool = ..., errors: str = ...) -> _P: ...
@overload
def smart_bytes(s: _B, encoding: Literal["utf-8"] = ..., *, errors: str = ...) -> _B: ...
def smart_bytes(s: _B, encoding: Literal["utf-8"] = "utf-8", *, errors: str = ...) -> _B: ...
@overload
def smart_bytes(s: Any, encoding: str = ..., *, errors: str = ...) -> bytes: ...
@overload
def smart_bytes(s: _PT, encoding: str = ..., strings_only: Literal[True] = ..., errors: str = ...) -> _PT: ...
def smart_bytes(s: _PT, encoding: str = ..., strings_only: Literal[True] = True, errors: str = ...) -> _PT: ...
@overload
def smart_bytes(s: Any, encoding: str = ..., strings_only: bool = ..., errors: str = ...) -> bytes: ...
@overload
def force_bytes(s: _B, encoding: Literal["utf-8"] = ..., *, errors: str = ...) -> _B: ...
def force_bytes(s: _B, encoding: Literal["utf-8"] = "utf-8", *, errors: str = ...) -> _B: ...
@overload
def force_bytes(s: Any, encoding: str = ..., *, errors: str = ...) -> bytes: ...
@overload
def force_bytes(s: _PT, encoding: str = ..., strings_only: Literal[True] = ..., errors: str = ...) -> _PT: ...
def force_bytes(s: _PT, encoding: str = ..., strings_only: Literal[True] = True, errors: str = ...) -> _PT: ...
@overload
def force_bytes(s: Any, encoding: str = ..., strings_only: bool = ..., errors: str = ...) -> bytes: ...
@overload
Expand Down

0 comments on commit e78d129

Please sign in to comment.