|
9 | 9 |
|
10 | 10 | - case: some_positional_args_fields |
11 | 11 | main: | |
| 12 | + from datetime import datetime, time |
12 | 13 | from django.db import models |
13 | | - from rest_framework.fields import DecimalField, IPAddressField, SlugField, RegexField, ModelField, SerializerMethodField, ChoiceField |
| 14 | + from rest_framework.fields import DecimalField, IPAddressField, SlugField, RegexField, ModelField, SerializerMethodField, ChoiceField, DateTimeField, DateField, TimeField |
14 | 15 |
|
15 | | - DecimalField(1, 1, False, 1, 1, False, None, True) |
16 | | - DecimalField(1, 1, False, 1, 1, False, None, True, True) # E: Too many positional arguments for "DecimalField" |
| 16 | + DecimalField(1, 1, False, 1, 1, False, None) |
| 17 | + DecimalField(1, 1, False, 1, 1, False, None, True) # E: Too many positional arguments for "DecimalField" |
17 | 18 |
|
18 | 19 | IPAddressField('both') |
19 | 20 | IPAddressField('both', True) # E: Too many positional arguments for "IPAddressField" |
|
34 | 35 | ChoiceField([]) |
35 | 36 | ChoiceField([], False) # E: Too many positional arguments for "ChoiceField" |
36 | 37 |
|
37 | | -- case: most_positional_args_fields |
38 | | - main: | |
39 | | - from rest_framework.fields import Field, ListField, DictField, JSONField |
40 | | - f: Field = Field() |
41 | | -
|
42 | | - ListField(True, True, True, [{"key": "value"}], [{"key": "value"}], 'src', 'l', 'ht', {"key": "value"}, {"key": "value"}, [lambda x: None], True) |
43 | | - ListField(True, True, True, [{"key": "value"}], [{"key": "value"}], 'src', 'l', 'ht', {"key": "value"}, {"key": "value"}, [lambda x: None], True, f) # E: Too many positional arguments for "ListField" |
44 | | - ListField(True, True, True, [{"key": "value"}], [{"key": "value"}], 'src', 'l', 'ht', {"key": "value"}, {"key": "value"}, [lambda x: None], True, child=f, allow_empty=True, max_length=1, min_length=1) |
45 | | -
|
46 | | - DictField(True, True, True, {}, {}, 'src', 'l', 'ht', {}, {}, [], True) |
47 | | - DictField(True, True, True, {}, {}, 'src', 'l', 'ht', {}, {}, [], True, f) # E: Too many positional arguments for "DictField" |
48 | | - DictField(True, True, True, {}, {}, 'src', 'l', 'ht', {}, {}, [], True, child=f, allow_empty=True) |
49 | | -
|
50 | | - JSONField(True, True, True, {}, {}, 'src', 'l', 'ht', {}, {}, [], True) |
51 | | - JSONField(True, True, True, {}, {}, 'src', 'l', 'ht', {}, {}, [], True, True) # E: Too many positional arguments for "JSONField" |
52 | | - JSONField(True, True, True, {}, {}, 'src', 'l', 'ht', {}, {}, [], True, binary=True, encoder=None, decoder=None) |
53 | | -
|
54 | | -- case: all_positional_args_fields |
55 | | - main: | |
56 | | - from datetime import datetime, time |
57 | | - from rest_framework.fields import DateTimeField, DateField, TimeField |
58 | | -
|
59 | 38 | d: datetime = datetime.now() |
60 | | - DateTimeField('', [], None, True, True, True, d, d, 'src', 'l', 'ht', {}, {}, [], True) |
61 | | - DateTimeField('', [], None, True, True, True, d, d, 'src', 'l', 'ht', {}, {}, [], True, 1) # E: Too many arguments for "DateTimeField" |
| 39 | + DateTimeField('', [], None, read_only=True, write_only=True, allow_null=True) |
| 40 | + DateTimeField('', [], None, True) # E: Too many positional arguments for "DateTimeField" |
62 | 41 |
|
63 | | - DateField('', [], True, True, True, d, d, 'src', 'l', 'ht', {}, {}, [], True) |
64 | | - DateField('', [], True, True, True, d, d, 'src', 'l', 'ht', {}, {}, [], True, 1) # E: Too many arguments for "DateField" |
| 42 | + DateField('', [], read_only=True, write_only=True, allow_null=True) |
| 43 | + DateField('', [], True) # E: Too many positional arguments for "DateField" |
65 | 44 |
|
66 | | - TimeField('', [], True, True, True, time(hour=1), time(hour=1), 'src', 'l', 'ht', {}, {}, [], True) |
67 | | - TimeField('', [], True, True, True, time(hour=1), time(hour=1), 'src', 'l', 'ht', {}, {}, [], True, 1) # E: Too many arguments for "TimeField" |
| 45 | + TimeField('', [], read_only=True, write_only=True, allow_null=True) |
| 46 | + TimeField('', [], True) # E: Too many positional arguments for "TimeField" |
68 | 47 |
|
69 | 48 | - case: default_and_inital_args_fields |
70 | 49 | main: | |
|
107 | 86 | def int_set_callback() -> Set[int]: ... |
108 | 87 | def mixed_set_callback() -> Set[Union[int, str]]: ... |
109 | 88 |
|
110 | | - MultipleChoiceField([1], default={1}) |
111 | | - MultipleChoiceField(['test'], allow_null=True, default=None) |
112 | | - MultipleChoiceField([1], default=int_set_callback) |
113 | | - MultipleChoiceField([1, 'lulz'], default=mixed_set_callback) |
114 | | - MultipleChoiceField([1], default=lambda: [1]) # E: Argument "default" to "MultipleChoiceField" has incompatible type "Callable[[], List[int]]"; expected "Union[Set[Union[str, int]], Set[str], Set[int], Callable[[], Union[Set[Union[str, int]], Set[str], Set[int]]], None, _Empty]" # E: Incompatible return value type (got "List[int]", expected "Union[Set[Union[str, int]], Set[str], Set[int]]") |
| 89 | + MultipleChoiceField(choices=[1], default={1}) |
| 90 | + MultipleChoiceField(choices=['test'], allow_null=True, default=None) |
| 91 | + MultipleChoiceField(choices=[1], default=int_set_callback) |
| 92 | + MultipleChoiceField(choices=[1, 'lulz'], default=mixed_set_callback) |
| 93 | + MultipleChoiceField(choices=[1], default=lambda: [1]) # E: Argument "default" to "MultipleChoiceField" has incompatible type "Callable[[], List[int]]"; expected "Union[Set[Union[str, int]], Set[str], Set[int], Callable[[], Union[Set[Union[str, int]], Set[str], Set[int]]], None, _Empty]" # E: Incompatible return value type (got "List[int]", expected "Union[Set[Union[str, int]], Set[str], Set[int]]") |
115 | 94 |
|
116 | 95 | MultipleChoiceField(choices=[(1, "1"), (2, "2")], default={1}) |
117 | 96 | MultipleChoiceField(choices=[(1, "1"), (2, "2")], default=[1]) # E: Argument "default" to "MultipleChoiceField" has incompatible type "List[int]"; expected "Union[Set[Union[str, int]], Set[str], Set[int], Callable[[], Union[Set[Union[str, int]], Set[str], Set[int]]], None, _Empty]" |
|
0 commit comments