Skip to content

Commit cd007f7

Browse files
committed
revert changes done in typeddjango#1253 that satisfy Y041, disable Y041 rule
Signed-off-by: Oleg Hoefling <[email protected]>
1 parent 377d432 commit cd007f7

File tree

10 files changed

+32
-32
lines changed

10 files changed

+32
-32
lines changed

django-stubs/core/paginator.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ class Paginator(Generic[_T]):
3131
allow_empty_first_page: bool = ...,
3232
) -> None: ...
3333
def __iter__(self) -> Iterator[Page[_T]]: ...
34-
def validate_number(self, number: float | str) -> int: ...
35-
def get_page(self, number: float | str | None) -> Page[_T]: ...
34+
def validate_number(self, number: int | float | str) -> int: ...
35+
def get_page(self, number: int | float | str | None) -> Page[_T]: ...
3636
def page(self, number: int | str) -> Page[_T]: ...
3737
@property
3838
def count(self) -> int: ...
@@ -41,7 +41,7 @@ class Paginator(Generic[_T]):
4141
@property
4242
def page_range(self) -> range: ...
4343
def get_elided_page_range(
44-
self, number: float | str = ..., *, on_each_side: int = ..., on_ends: int = ...
44+
self, number: int | float | str = ..., *, on_each_side: int = ..., on_ends: int = ...
4545
) -> Iterator[str | int]: ...
4646

4747
QuerySetPaginator: TypeAlias = Paginator

django-stubs/db/models/fields/__init__.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]):
221221
def value_to_string(self, obj: Model) -> str: ...
222222

223223
class IntegerField(Field[_ST, _GT]):
224-
_pyi_private_set_type: float | str | Combinable
224+
_pyi_private_set_type: float | int | str | Combinable
225225
_pyi_private_get_type: int
226226
_pyi_lookup_exact_type: str | int
227227

@@ -235,7 +235,7 @@ class SmallIntegerField(IntegerField[_ST, _GT]): ...
235235
class BigIntegerField(IntegerField[_ST, _GT]): ...
236236

237237
class FloatField(Field[_ST, _GT]):
238-
_pyi_private_set_type: float | str | Combinable
238+
_pyi_private_set_type: float | int | str | Combinable
239239
_pyi_private_get_type: float
240240
_pyi_lookup_exact_type: float
241241

django-stubs/db/models/lookups.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ class IntegerFieldFloatRounding:
8383
rhs: Any
8484
def get_prep_lookup(self) -> Any: ...
8585

86-
class IntegerGreaterThanOrEqual(IntegerFieldFloatRounding, GreaterThanOrEqual[float]): ...
87-
class IntegerLessThan(IntegerFieldFloatRounding, LessThan[float]): ...
86+
class IntegerGreaterThanOrEqual(IntegerFieldFloatRounding, GreaterThanOrEqual[int | float]): ...
87+
class IntegerLessThan(IntegerFieldFloatRounding, LessThan[int | float]): ...
8888

8989
class In(FieldGetDbPrepValueIterableMixin, BuiltinLookup):
9090
def split_parameter_list_as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> Any: ...

django-stubs/forms/fields.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ class FloatField(IntegerField):
122122
def __init__(
123123
self,
124124
*,
125-
max_value: float | None = ...,
126-
min_value: float | None = ...,
125+
max_value: int | float | None = ...,
126+
min_value: int | float | None = ...,
127127
required: bool = ...,
128128
widget: Widget | type[Widget] | None = ...,
129129
label: _StrOrPromise | None = ...,
@@ -146,8 +146,8 @@ class DecimalField(IntegerField):
146146
def __init__(
147147
self,
148148
*,
149-
max_value: Decimal | float | None = ...,
150-
min_value: Decimal | float | None = ...,
149+
max_value: Decimal | int | float | None = ...,
150+
min_value: Decimal | int | float | None = ...,
151151
max_digits: int | None = ...,
152152
decimal_places: int | None = ...,
153153
required: bool = ...,

django-stubs/template/defaultfilters.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def default(value: int | str | None, arg: int | str) -> int | str: ...
6363
def default_if_none(value: str | None, arg: int | str) -> int | str: ...
6464
def divisibleby(value: int, arg: int) -> bool: ...
6565
def yesno(value: int | None, arg: str | None = ...) -> bool | str | None: ...
66-
def filesizeformat(bytes_: complex | str) -> str: ...
66+
def filesizeformat(bytes_: complex | int | str) -> str: ...
6767
def pluralize(value: Any, arg: str = ...) -> str: ...
6868
def phone2numeric_filter(value: str) -> str: ...
6969
def pprint(value: Any) -> str: ...

django-stubs/test/testcases.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,13 @@ class SimpleTestCase(unittest.TestCase):
167167
def assertJSONEqual(
168168
self,
169169
raw: str,
170-
expected_data: dict[str, Any] | list[Any] | str | float | bool | None,
170+
expected_data: dict[str, Any] | list[Any] | str | int | float | bool | None,
171171
msg: str | None = ...,
172172
) -> None: ...
173173
def assertJSONNotEqual(
174174
self,
175175
raw: str,
176-
expected_data: dict[str, Any] | list[Any] | str | float | bool | None,
176+
expected_data: dict[str, Any] | list[Any] | str | int | float | bool | None,
177177
msg: str | None = ...,
178178
) -> None: ...
179179
def assertXMLEqual(self, xml1: str, xml2: str, msg: str | None = ...) -> None: ...

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ exclude = .*/
33
extend-ignore = E203
44
max_line_length = 120
55
per-file-ignores =
6-
*.pyi: B, E301, E302, E305, E501, E701, E741, E743, NQA102, F401, F403, F405, F822, Y021, Y024, Y043
6+
*.pyi: B, E301, E302, E305, E501, E701, E741, E743, NQA102, F401, F403, F405, F822, Y021, Y024, Y041, Y043
77

88
[metadata]
99
license_file = LICENSE.txt

tests/typecheck/fields/test_related.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,9 @@
387387
388388
reveal_type(Book2().publisher_id) # N: Revealed type is "builtins.int"
389389
Book2(publisher_id=1)
390-
Book2(publisher_id=[]) # E: Incompatible type for "publisher_id" of "Book2" (got "List[Any]", expected "Union[float, str, Combinable]")
390+
Book2(publisher_id=[]) # E: Incompatible type for "publisher_id" of "Book2" (got "List[Any]", expected "Union[float, int, str, Combinable]")
391391
Book2.objects.create(publisher_id=1)
392-
Book2.objects.create(publisher_id=[]) # E: Incompatible type for "publisher_id" of "Book2" (got "List[Any]", expected "Union[float, str, Combinable]")
392+
Book2.objects.create(publisher_id=[]) # E: Incompatible type for "publisher_id" of "Book2" (got "List[Any]", expected "Union[float, int, str, Combinable]")
393393
installed_apps:
394394
- myapp
395395
files:

tests/typecheck/models/test_create.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
main: |
33
from myapp.models import User
44
User.objects.create(pk=1, name='Max', age=10)
5-
User.objects.create(age=[]) # E: Incompatible type for "age" of "User" (got "List[Any]", expected "Union[float, str, Combinable]")
5+
User.objects.create(age=[]) # E: Incompatible type for "age" of "User" (got "List[Any]", expected "Union[float, int, str, Combinable]")
66
installed_apps:
77
- myapp
88
files:
@@ -62,7 +62,7 @@
6262
main: |
6363
from myapp.models import Publisher, Book
6464
65-
Book.objects.create(id=None) # E: Incompatible type for "id" of "Book" (got "None", expected "Union[float, str, Combinable]")
65+
Book.objects.create(id=None) # E: Incompatible type for "id" of "Book" (got "None", expected "Union[float, int, str, Combinable]")
6666
Book.objects.create(publisher=None) # E: Incompatible type for "publisher" of "Book" (got "None", expected "Union[Publisher, Combinable]")
6767
Book.objects.create(publisher_id=None) # E: Incompatible type for "publisher_id" of "Book" (got "None", expected "Union[Combinable, int, str]")
6868
installed_apps:
@@ -104,18 +104,18 @@
104104
reveal_type(first.id) # N: Revealed type is "builtins.int"
105105
106106
from myapp.models import MyModel2
107-
MyModel2(id=None) # E: Incompatible type for "id" of "MyModel2" (got "None", expected "Union[float, str, Combinable]")
108-
MyModel2.objects.create(id=None) # E: Incompatible type for "id" of "MyModel2" (got "None", expected "Union[float, str, Combinable]")
107+
MyModel2(id=None) # E: Incompatible type for "id" of "MyModel2" (got "None", expected "Union[float, int, str, Combinable]")
108+
MyModel2.objects.create(id=None) # E: Incompatible type for "id" of "MyModel2" (got "None", expected "Union[float, int, str, Combinable]")
109109
second = MyModel2()
110-
second.id = None # E: Incompatible types in assignment (expression has type "None", variable has type "Union[float, str, Combinable]")
110+
second.id = None # E: Incompatible types in assignment (expression has type "None", variable has type "Union[float, int, str, Combinable]")
111111
reveal_type(second.id) # N: Revealed type is "builtins.int"
112112
113113
# default set but no primary key doesn't allow None
114114
from myapp.models import MyModel3
115-
MyModel3(default=None) # E: Incompatible type for "default" of "MyModel3" (got "None", expected "Union[float, str, Combinable]")
116-
MyModel3.objects.create(default=None) # E: Incompatible type for "default" of "MyModel3" (got "None", expected "Union[float, str, Combinable]")
115+
MyModel3(default=None) # E: Incompatible type for "default" of "MyModel3" (got "None", expected "Union[float, int, str, Combinable]")
116+
MyModel3.objects.create(default=None) # E: Incompatible type for "default" of "MyModel3" (got "None", expected "Union[float, int, str, Combinable]")
117117
third = MyModel3()
118-
third.default = None # E: Incompatible types in assignment (expression has type "None", variable has type "Union[float, str, Combinable]")
118+
third.default = None # E: Incompatible types in assignment (expression has type "None", variable has type "Union[float, int, str, Combinable]")
119119
reveal_type(third.default) # N: Revealed type is "builtins.int"
120120
installed_apps:
121121
- myapp

tests/typecheck/models/test_init.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from myapp.models import MyUser
3838
user = MyUser(name='hello', age=[])
3939
out: |
40-
main:2: error: Incompatible type for "age" of "MyUser" (got "List[Any]", expected "Union[float, str, Combinable]")
40+
main:2: error: Incompatible type for "age" of "MyUser" (got "List[Any]", expected "Union[float, int, str, Combinable]")
4141
installed_apps:
4242
- myapp
4343
files:
@@ -107,7 +107,7 @@
107107
- case: typechecking_of_pk
108108
main: |
109109
from myapp.models import MyUser1
110-
user = MyUser1(pk=[]) # E: Incompatible type for "pk" of "MyUser1" (got "List[Any]", expected "Union[float, str, Combinable, None]")
110+
user = MyUser1(pk=[]) # E: Incompatible type for "pk" of "MyUser1" (got "List[Any]", expected "Union[float, int, str, Combinable, None]")
111111
installed_apps:
112112
- myapp
113113
files:
@@ -155,11 +155,11 @@
155155
class NotAValid:
156156
pass
157157
array_val3: List[NotAValid] = [NotAValid()]
158-
MyModel(array=array_val3) # E: Incompatible type for "array" of "MyModel" (got "List[NotAValid]", expected "Union[Sequence[Union[float, str]], Combinable]")
158+
MyModel(array=array_val3) # E: Incompatible type for "array" of "MyModel" (got "List[NotAValid]", expected "Union[Sequence[Union[float, int, str]], Combinable]")
159159
non_init = MyModel()
160160
non_init.array = array_val
161161
non_init.array = array_val2
162-
non_init.array = array_val3 # E: Incompatible types in assignment (expression has type "List[NotAValid]", variable has type "Union[Sequence[Union[float, str]], Combinable]")
162+
non_init.array = array_val3 # E: Incompatible types in assignment (expression has type "List[NotAValid]", variable has type "Union[Sequence[Union[float, int, str]], Combinable]")
163163
installed_apps:
164164
- myapp
165165
files:
@@ -191,7 +191,7 @@
191191
from myapp.models import MyModel, MyModel2
192192
MyModel(1)
193193
MyModel2(1, 12)
194-
MyModel2(1, []) # E: Incompatible type for "name" of "MyModel2" (got "List[Any]", expected "Union[float, str, Combinable]")
194+
MyModel2(1, []) # E: Incompatible type for "name" of "MyModel2" (got "List[Any]", expected "Union[float, int, str, Combinable]")
195195
installed_apps:
196196
- myapp
197197
files:
@@ -291,11 +291,11 @@
291291
main:9: error: Incompatible types in assignment (expression has type "str", variable has type "int")
292292
main:10: error: Incompatible types in assignment (expression has type "str", variable has type "Union[int, float]")
293293
main:12: error: Incompatible types in assignment (expression has type "List[str]", variable has type "Sequence[Union[int, float]]")
294-
main:13: error: Incompatible types in assignment (expression has type "List[<nothing>]", variable has type "Union[float, str, Combinable]")
294+
main:13: error: Incompatible types in assignment (expression has type "List[<nothing>]", variable has type "Union[float, int, str, Combinable]")
295295
main:15: error: Incompatible type for "redefined_set_type" of "MyModel" (got "str", expected "int")
296296
main:15: error: Incompatible type for "redefined_union_set_type" of "MyModel" (got "str", expected "Union[int, float]")
297297
main:15: error: Incompatible type for "redefined_array_set_type" of "MyModel" (got "int", expected "Sequence[Union[int, float]]")
298-
main:15: error: Incompatible type for "default_set_type" of "MyModel" (got "List[Any]", expected "Union[float, str, Combinable]")
298+
main:15: error: Incompatible type for "default_set_type" of "MyModel" (got "List[Any]", expected "Union[float, int, str, Combinable]")
299299
installed_apps:
300300
- myapp
301301
files:

0 commit comments

Comments
 (0)