Skip to content

Commit 7f47605

Browse files
authored
Refactors bad default values, now using Ellipsis (#132)
* Refactors bad default values, now using Ellipsis * Blacked
1 parent d315128 commit 7f47605

File tree

9 files changed

+49
-24
lines changed

9 files changed

+49
-24
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Check http://editorconfig.org for more information
2+
# This is the main config file for this project:
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
end_of_line = lf
8+
insert_final_newline = true
9+
indent_style = space
10+
indent_size = 2
11+
trim_trailing_whitespace = true
12+
13+
[*.py]
14+
indent_style = space
15+
indent_size = 4

django-stubs/contrib/postgres/search.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class SearchVectorCombinable:
1313
ADD: str = ...
1414

1515
class SearchVector(SearchVectorCombinable, Func):
16-
config: Optional[Any] = None
16+
config: Optional[Any] = ...
1717
def __init__(self, *expressions: Union[str, Combinable], **extra: Any): ...
1818

1919
class CombinedSearchVector(SearchVectorCombinable, CombinedExpression):
@@ -31,11 +31,11 @@ class SearchQueryCombinable:
3131

3232
class SearchQuery(SearchQueryCombinable, Value):
3333
SEARCH_TYPES: Dict[str, str] = {"plain": "plainto_tsquery", "phrase": "phraseto_tsquery", "raw": "to_tsquery"}
34-
def __init__(self, value, output_field=None, *, config=None, invert=False, search_type="plain"): ...
34+
def __init__(self, value, output_field=..., *, config=..., invert=False, search_type="plain"): ...
3535
def __invert__(self: _T) -> _T: ...
3636

3737
class CombinedSearchQuery(SearchQueryCombinable, CombinedExpression):
38-
def __init__(self, lhs, connector, rhs, config, output_field=None) -> None: ...
38+
def __init__(self, lhs, connector, rhs, config, output_field=...) -> None: ...
3939

4040
class SearchRank(Func):
4141
def __init__(self, vector, query, **extra: Any) -> None: ...

django-stubs/core/files/uploadhandler.pyi

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,39 @@ class FileUploadHandler:
2323
content_type_extra = ... # type: Optional[Dict[str, str]]
2424
request = ... # type: Optional[HttpRequest]
2525
field_name = ... # type: str
26-
def __init__(self, request: HttpRequest = None) -> None: ...
26+
def __init__(self, request: Optional[HttpRequest] = ...) -> None: ...
2727
def handle_raw_input(
28-
self, input_data: IO[bytes], META: Dict[str, str], content_length: int, boundary: str, encoding: str = None
28+
self,
29+
input_data: IO[bytes],
30+
META: Dict[str, str],
31+
content_length: int,
32+
boundary: str,
33+
encoding: Optional[str] = ...,
2934
) -> Optional[Tuple[QueryDict, MultiValueDict[str, UploadedFile]]]: ...
3035
def new_file(
3136
self,
3237
field_name: str,
3338
file_name: str,
3439
content_type: str,
3540
content_length: Optional[int],
36-
charset: str = None,
37-
content_type_extra: Dict[str, str] = None,
41+
charset: Optional[str] = ...,
42+
content_type_extra: Optional[Dict[str, str]] = ...,
3843
) -> None: ...
3944
def receive_data_chunk(self, raw_data: bytes, start: int) -> Optional[bytes]: ...
4045
def file_complete(self, file_size: int) -> Optional[UploadedFile]: ...
4146
def upload_complete(self) -> None: ...
4247

4348
class TemporaryFileUploadHandler(FileUploadHandler):
44-
def __init__(self, request: HttpRequest = None) -> None: ...
49+
def __init__(self, request: Optional[HttpRequest] = ...) -> None: ...
4550
file = ... # type: TemporaryUploadedFile
4651
def new_file(
4752
self,
4853
field_name: str,
4954
file_name: str,
5055
content_type: str,
5156
content_length: Optional[int],
52-
charset: str = None,
53-
content_type_extra: Dict[str, str] = None,
57+
charset: Optional[str] = ...,
58+
content_type_extra: Optional[Dict[str, str]] = ...,
5459
) -> None: ...
5560
def receive_data_chunk(self, raw_data: bytes, start: int) -> Optional[bytes]: ...
5661
def file_complete(self, file_size: int) -> Optional[UploadedFile]: ...
@@ -59,16 +64,21 @@ class MemoryFileUploadHandler(FileUploadHandler):
5964
activated = ... # type: bool
6065
file = ... # type: IO[bytes]
6166
def handle_raw_input(
62-
self, input_data: IO[bytes], META: Dict[str, str], content_length: int, boundary: str, encoding: str = None
67+
self,
68+
input_data: IO[bytes],
69+
META: Dict[str, str],
70+
content_length: int,
71+
boundary: str,
72+
encoding: Optional[str] = ...,
6373
) -> Optional[Tuple[QueryDict, MultiValueDict[str, UploadedFile]]]: ...
6474
def new_file(
6575
self,
6676
field_name: str,
6777
file_name: str,
6878
content_type: str,
6979
content_length: Optional[int],
70-
charset: str = None,
71-
content_type_extra: Dict[str, str] = None,
80+
charset: Optional[str] = ...,
81+
content_type_extra: Optional[Dict[str, str]] = ...,
7282
) -> None: ...
7383
def receive_data_chunk(self, raw_data: bytes, start: int) -> Optional[bytes]: ...
7484
def file_complete(self, file_size: int) -> Optional[UploadedFile]: ...

django-stubs/db/models/query.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class RawQuerySet(Iterable[_T], Sized):
184184
def using(self, alias: Optional[str]) -> RawQuerySet[_T]: ...
185185

186186
class Prefetch(object):
187-
def __init__(self, lookup: str, queryset: Optional[QuerySet] = None, to_attr: Optional[str] = None) -> None: ...
187+
def __init__(self, lookup: str, queryset: Optional[QuerySet] = ..., to_attr: Optional[str] = ...) -> None: ...
188188
def __getstate__(self) -> Dict[str, Any]: ...
189189
def add_prefix(self, prefix: str) -> None: ...
190190
def get_current_prefetch_to(self, level: int) -> str: ...

django-stubs/db/transaction.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ def atomic(using: _C) -> _C: ...
3838

3939
# Decorator or context-manager with parameters
4040
@overload
41-
def atomic(using: Optional[str] = None, savepoint: bool = True) -> Atomic: ...
41+
def atomic(using: Optional[str] = ..., savepoint: bool = True) -> Atomic: ...
4242
def non_atomic_requests(using: Callable = ...) -> Callable: ...

django-stubs/http/response.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class HttpResponseBase(Iterable[Any]):
4949
) -> None: ...
5050
def setdefault(self, key: str, value: str) -> None: ...
5151
def set_signed_cookie(self, key: str, value: str, salt: str = "", **kwargs: Any) -> None: ...
52-
def delete_cookie(self, key: str, path: str = "", domain: str = None) -> None: ...
52+
def delete_cookie(self, key: str, path: str = "", domain: Optional[str] = ...) -> None: ...
5353
def make_bytes(self, value: object) -> bytes: ...
5454
def close(self) -> None: ...
5555
def write(self, content: Union[str, bytes]) -> None: ...

django-stubs/utils/datastructures.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class MultiValueDict(MutableMapping[_K, _V]):
3939
def __init__(self, key_to_list_mapping: Iterable[Tuple[_K, List[_V]]] = ...) -> None: ...
4040
def getlist(self, key: _K, default: Any = ...) -> List[_V]: ...
4141
def setlist(self, key: _K, list_: List[_V]) -> None: ...
42-
def setlistdefault(self, key: _K, default_list: List[_V] = None) -> List[_V]: ...
42+
def setlistdefault(self, key: _K, default_list: Optional[List[_V]] = ...) -> List[_V]: ...
4343
def appendlist(self, key: _K, value: _V) -> None: ...
4444
def lists(self) -> Iterable[Tuple[_K, List[_V]]]: ...
4545
def dict(self) -> Dict[_K, Union[_V, List[_V]]]: ...

django-stubs/views/generic/edit.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class FormMixin(ContextMixin):
1717
def get_initial(self) -> Dict[str, Any]: ...
1818
def get_prefix(self) -> Optional[str]: ...
1919
def get_form_class(self) -> Type[BaseForm]: ...
20-
def get_form(self, form_class: Optional[Type[BaseForm]] = None) -> BaseForm: ...
20+
def get_form(self, form_class: Optional[Type[BaseForm]] = ...) -> BaseForm: ...
2121
def get_form_kwargs(self) -> Dict[str, Any]: ...
2222
def get_success_url(self) -> str: ...
2323
def form_valid(self, form: BaseForm) -> HttpResponse: ...

setup.cfg

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
[isort]
22
skip =
3-
django-sources,
4-
django-stubs,
5-
test-data
3+
django-sources
4+
django-stubs
5+
test-data
66
include_trailing_comma = true
77
multi_line_output = 5
88
wrap_length = 120
99

1010
[flake8]
1111
exclude =
12-
django-sources,
13-
django-stubs,
14-
test-data
12+
django-sources
13+
django-stubs
14+
test-data
1515
max_line_length = 120
1616

1717
[metadata]

0 commit comments

Comments
 (0)