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

Cleanup: Add missing None return to __init__ methods #492

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
46 changes: 23 additions & 23 deletions rest_framework-stubs/fields.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class Field(Generic[_VT, _DT, _RP, _IN]):
error_messages: dict[str, StrOrPromise] = ...,
validators: Sequence[Validator[_VT]] | None = ...,
allow_null: bool = ...,
): ...
) -> None: ...
def bind(self, field_name: str, parent: BaseSerializer) -> None: ...
@property
def validators(self) -> list[Validator[_VT]]: ...
Expand Down Expand Up @@ -173,7 +173,7 @@ class CharField(Field[str, str, str, Any]):
trim_whitespace: bool = ...,
max_length: int = ...,
min_length: int | None = ...,
): ...
) -> None: ...

class EmailField(CharField): ...

Expand All @@ -198,7 +198,7 @@ class RegexField(CharField):
trim_whitespace: bool = ...,
max_length: int = ...,
min_length: int | None = ...,
): ...
) -> None: ...

class SlugField(CharField):
allow_unicode: bool
Expand All @@ -222,7 +222,7 @@ class SlugField(CharField):
trim_whitespace: bool = ...,
max_length: int = ...,
min_length: int | None = ...,
): ...
) -> None: ...

class URLField(CharField): ...

Expand All @@ -245,7 +245,7 @@ class UUIDField(Field[uuid.UUID, uuid.UUID | str | int, str, Any]):
error_messages: dict[str, StrOrPromise] = ...,
validators: Sequence[Validator[uuid.UUID]] | None = ...,
allow_null: bool = ...,
): ...
) -> None: ...

class IPAddressField(CharField):
protocol: str
Expand All @@ -270,7 +270,7 @@ class IPAddressField(CharField):
trim_whitespace: bool = ...,
max_length: int = ...,
min_length: int | None = ...,
): ...
) -> None: ...

class IntegerField(Field[int, float | int | str, int, Any]):
MAX_STRING_LENGTH: int
Expand All @@ -294,7 +294,7 @@ class IntegerField(Field[int, float | int | str, int, Any]):
error_messages: dict[str, StrOrPromise] = ...,
validators: Sequence[Validator[int]] | None = ...,
allow_null: bool = ...,
): ...
) -> None: ...

class FloatField(Field[float, float | int | str, str, Any]):
MAX_STRING_LENGTH: int
Expand All @@ -318,7 +318,7 @@ class FloatField(Field[float, float | int | str, str, Any]):
error_messages: dict[str, StrOrPromise] = ...,
validators: Sequence[Validator[float]] | None = ...,
allow_null: bool = ...,
): ...
) -> None: ...

class DecimalField(Field[Decimal, int | float | str | Decimal, str, Any]):
MAX_STRING_LENGTH: int
Expand Down Expand Up @@ -353,7 +353,7 @@ class DecimalField(Field[Decimal, int | float | str | Decimal, str, Any]):
error_messages: dict[str, StrOrPromise] = ...,
validators: Sequence[Validator[Decimal]] | None = ...,
allow_null: bool = ...,
): ...
) -> None: ...
def validate_precision(self, value: Decimal) -> Decimal: ...
def quantize(self, value: Decimal) -> Decimal: ...

Expand All @@ -379,7 +379,7 @@ class DateTimeField(Field[datetime.datetime, datetime.datetime | str, str, Any])
error_messages: dict[str, StrOrPromise] = ...,
validators: Sequence[Validator[datetime.datetime]] | None = ...,
allow_null: bool = ...,
): ...
) -> None: ...
def enforce_timezone(self, value: datetime.datetime) -> datetime.datetime: ...
def default_timezone(self) -> str | None: ...

Expand All @@ -403,7 +403,7 @@ class DateField(Field[datetime.date, datetime.date | str, str, Any]):
error_messages: dict[str, StrOrPromise] = ...,
validators: Sequence[Validator[datetime.date]] | None = ...,
allow_null: bool = ...,
): ...
) -> None: ...

class TimeField(Field[datetime.time, datetime.time | str, str, Any]):
datetime_parser: Callable[[str, str], datetime.datetime]
Expand All @@ -425,7 +425,7 @@ class TimeField(Field[datetime.time, datetime.time | str, str, Any]):
error_messages: dict[str, StrOrPromise] = ...,
validators: Sequence[Validator[datetime.time]] | None = ...,
allow_null: bool = ...,
): ...
) -> None: ...

class DurationField(Field[datetime.timedelta, datetime.timedelta | str, str, Any]):
max_value: datetime.timedelta | None
Expand All @@ -447,7 +447,7 @@ class DurationField(Field[datetime.timedelta, datetime.timedelta | str, str, Any
error_messages: dict[str, StrOrPromise] = ...,
validators: Sequence[Validator[datetime.timedelta]] | None = ...,
allow_null: bool = ...,
): ...
) -> None: ...

class ChoiceField(Field[str, str | int | tuple[str | int, str | int | tuple], str, Any]):
html_cutoff: int | None
Expand Down Expand Up @@ -475,7 +475,7 @@ class ChoiceField(Field[str, str | int | tuple[str | int, str | int | tuple], st
html_cutoff: int = ...,
html_cutoff_text: StrOrPromise = ...,
allow_blank: bool = ...,
): ...
) -> None: ...
def iter_options(self) -> Iterable[Option]: ...
def _get_choices(self) -> dict[Any, Any]: ...
def _set_choices(self, choices: Iterable[Any]) -> None: ...
Expand Down Expand Up @@ -510,7 +510,7 @@ class MultipleChoiceField(
html_cutoff_text: StrOrPromise = ...,
allow_blank: bool = ...,
allow_empty: bool = ...,
): ...
) -> None: ...

class FilePathField(ChoiceField):
def __init__(
Expand All @@ -535,7 +535,7 @@ class FilePathField(ChoiceField):
html_cutoff: int = ...,
html_cutoff_text: StrOrPromise = ...,
allow_blank: bool = ...,
): ...
) -> None: ...

class FileField(Field[File, File, str | None, Any]): # this field can return None without raising!
max_length: int
Expand All @@ -559,7 +559,7 @@ class FileField(Field[File, File, str | None, Any]): # this field can return No
max_length: int = ...,
allow_empty_file: bool = ...,
use_url: bool = ...,
): ...
) -> None: ...

class ImageField(FileField):
_DjangoImageField: SupportsToPython
Expand All @@ -582,7 +582,7 @@ class ImageField(FileField):
allow_empty_file: bool = ...,
use_url: bool = ...,
_DjangoImageField: type[SupportsToPython] = ...,
): ...
) -> None: ...

class _UnvalidatedField(Field): ...

Expand Down Expand Up @@ -610,7 +610,7 @@ class ListField(Field[list[Any], list[Any], list[Any], Any]):
allow_empty: bool = ...,
max_length: int = ...,
min_length: int = ...,
): ...
) -> None: ...
def run_child_validation(self, data: list[Mapping[Any, Any]]) -> Any: ...

class DictField(Field[dict[Any, Any], dict[Any, Any], dict[Any, Any], Any]):
Expand All @@ -633,7 +633,7 @@ class DictField(Field[dict[Any, Any], dict[Any, Any], dict[Any, Any], Any]):
*,
child: Field = ...,
allow_empty: bool = ...,
): ...
) -> None: ...
def run_child_validation(self, data: Any) -> Any: ...

class HStoreField(DictField):
Expand Down Expand Up @@ -661,7 +661,7 @@ class JSONField(Field[dict[str, Any] | list[dict[str, Any]], dict[str, Any] | li
binary: bool = ...,
encoder: type[JSONEncoder] | None = ...,
decoder: type[JSONDecoder] | None = ...,
): ...
) -> None: ...

class ReadOnlyField(Field): ...
class HiddenField(Field): ...
Expand All @@ -684,7 +684,7 @@ class SerializerMethodField(Field):
error_messages: dict[str, StrOrPromise] = ...,
validators: Sequence[Validator[Any]] | None = ...,
allow_null: bool = ...,
): ...
) -> None: ...

class ModelField(Field):
model_field: models.Field
Expand All @@ -706,4 +706,4 @@ class ModelField(Field):
validators: Sequence[Validator[Any]] | None = ...,
allow_null: bool = ...,
max_length: int = ...,
): ...
) -> None: ...
10 changes: 5 additions & 5 deletions rest_framework-stubs/relations.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class RelatedField(Generic[_MT, _DT, _PT], Field[_MT, _DT, _PT, Any]):
validators: Sequence[Validator[_MT]] | None = ...,
error_messages: dict[str, StrOrPromise] | None = ...,
style: dict[str, str] | None = ...,
): ...
) -> None: ...
# mypy doesn't accept the typing below, although its accurate to what this class is doing, hence the ignore
def __new__(cls, *args: Any, **kwargs: Any) -> RelatedField[_MT, _DT, _PT] | ManyRelatedField: ... # type: ignore
@classmethod
Expand Down Expand Up @@ -94,7 +94,7 @@ class PrimaryKeyRelatedField(RelatedField[_MT, _MT, Any]):
error_messages: dict[str, StrOrPromise] | None = ...,
style: dict[str, str] | None = ...,
pk_field: str | Field | None = ...,
): ...
) -> None: ...

class HyperlinkedRelatedField(RelatedField[_MT, str, Hyperlink]):
reverse: Callable
Expand Down Expand Up @@ -125,7 +125,7 @@ class HyperlinkedRelatedField(RelatedField[_MT, str, Hyperlink]):
lookup_field: str | None = ...,
lookup_url_kwarg: str | None = ...,
format: str | None = ...,
): ...
) -> None: ...
def get_object(self, view_name: str, *view_args: Any, **view_kwargs: Any) -> _MT: ...
def get_url(self, obj: Model, view_name: str, request: Request, format: str | None) -> str | None: ...

Expand Down Expand Up @@ -153,7 +153,7 @@ class SlugRelatedField(RelatedField[_MT, str, str]):
error_messages: dict[str, StrOrPromise] | None = ...,
style: dict[str, str] | None = ...,
slug_field: str | None = ...,
): ...
) -> None: ...
def to_internal_value(self, data: Any) -> _MT: ...
def to_representation(self, value: _MT) -> str: ...

Expand All @@ -179,7 +179,7 @@ class ManyRelatedField(Field[Sequence[Any], Sequence[Any], list[Any], Any]):
allow_null: bool = ...,
allow_empty: bool = ...,
child_relation: RelatedField = ...,
): ...
) -> None: ...
def get_value(self, dictionary: Mapping[Any, Any]) -> list[Any]: ...
def get_choices(self, cutoff: int | None = ...) -> dict: ...
@property
Expand Down
2 changes: 1 addition & 1 deletion rest_framework-stubs/response.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Response(SimpleTemplateResponse):
headers: Mapping[str, str] | None = ...,
exception: bool = ...,
content_type: str | None = ...,
): ...
) -> None: ...
@property
def rendered_content(self) -> Any: ...
def render(self) -> Any: ...
Expand Down
6 changes: 3 additions & 3 deletions rest_framework-stubs/serializers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class BaseSerializer(Generic[_IN], Field[Any, Any, Any, _IN]):
error_messages: dict[str, StrOrPromise] = ...,
validators: Sequence[Validator[Any]] | None = ...,
allow_null: bool = ...,
): ...
) -> None: ...
@classmethod
def many_init(cls, *args: Any, **kwargs: Any) -> BaseSerializer: ...
def is_valid(self, raise_exception: bool = ...) -> bool: ...
Expand Down Expand Up @@ -173,7 +173,7 @@ class ListSerializer(
allow_null: bool = ...,
min_length: int | None = ...,
max_length: int | None = ...,
): ...
) -> None: ...
def get_initial(self) -> list[Mapping[Any, Any]]: ...
def validate(self, attrs: Any) -> Any: ...
@property
Expand Down Expand Up @@ -219,7 +219,7 @@ class ModelSerializer(Serializer, BaseSerializer[_MT]):
validators: Sequence[Validator[_MT]] | None = ...,
allow_null: bool = ...,
allow_empty: bool = ...,
): ...
) -> None: ...
def update(self, instance: _MT, validated_data: Any) -> _MT: ...
def create(self, validated_data: Any) -> _MT: ...
def save(self, **kwargs: Any) -> _MT: ...
Expand Down
2 changes: 1 addition & 1 deletion rest_framework-stubs/settings.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class APISettings:
user_settings: DefaultsSettings | None = ...,
defaults: DefaultsSettings | None = ...,
import_strings: Sequence[str] | None = ...,
): ...
) -> None: ...
@property
def user_settings(self) -> Mapping[str, Any]: ...
def __getattr__(self, attr: str) -> Any: ...
Expand Down