|
51 | 51 | from typing import Optional, Dict, Any |
52 | 52 |
|
53 | 53 | CharField(initial='', default=lambda: '') |
54 | | - CharField(initial=None, default=4) # E: Argument "default" to "CharField" has incompatible type "int"; expected "Union[Union[str, _StrPromise], Callable[[], Union[str, _StrPromise]], None, _Empty]" |
55 | | - CharField(initial={}, default=empty) # E: Argument "initial" to "CharField" has incompatible type "Dict[Never, Never]"; expected "Union[str, Callable[[], str], None, _Empty]" |
| 54 | + CharField(initial=None, default=4) # E: Argument "default" to "CharField" has incompatible type "int"; expected "Union[Union[str, _StrPromise], Callable[[], Union[str, _StrPromise]], _Empty, None]" |
| 55 | + CharField(initial={}, default=empty) # E: Argument "initial" to "CharField" has incompatible type "Dict[Never, Never]"; expected "Union[str, Callable[[], str], _Empty, None]" |
56 | 56 |
|
57 | 57 | x: Optional[str] = CharField().get_initial() |
58 | 58 | y: Optional[int] = CharField().get_initial() # E: Incompatible types in assignment (expression has type "Optional[str]", variable has type "Optional[int]") |
|
76 | 76 | ChoiceField(['test'], allow_null=True, default=None) |
77 | 77 | ChoiceField([1], default=int_callback) |
78 | 78 | ChoiceField([1, 'lulz'], default=mixed_callback) |
79 | | - ChoiceField([1], default=lambda: None) # E: Argument "default" to "ChoiceField" has incompatible type "Callable[[], None]"; expected "Union[Union[str, _StrPromise], int, Callable[[], Union[Union[str, _StrPromise], int]], None, _Empty]" # E: Incompatible return value type (got "None", expected "Union[Union[str, _StrPromise], int]") |
| 79 | + ChoiceField([1], default=lambda: None) # E: Argument "default" to "ChoiceField" has incompatible type "Callable[[], None]"; expected "Union[Union[str, _StrPromise], int, Callable[[], Union[Union[str, _StrPromise], int]], _Empty, None]" # E: Incompatible return value type (got "None", expected "Union[Union[str, _StrPromise], int]") |
80 | 80 |
|
81 | 81 | - case: MultipleChoiceField_default |
82 | 82 | main: | |
|
90 | 90 | MultipleChoiceField(choices=['test'], allow_null=True, default=None) |
91 | 91 | MultipleChoiceField(choices=[1], default=int_set_callback) |
92 | 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]]") |
| 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]]], _Empty, None]" # E: Incompatible return value type (got "List[int]", expected "Union[Set[Union[str, int]], Set[str], Set[int]]") |
94 | 94 |
|
95 | 95 | MultipleChoiceField(choices=[(1, "1"), (2, "2")], default={1}) |
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]" |
| 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]]], _Empty, None]" |
97 | 97 |
|
98 | 98 | MultipleChoiceField(choices=[(1, "1"), (2, "2")], initial={1}) |
99 | | - MultipleChoiceField(choices=[(1, "1"), (2, "2")], initial=[1]) # E: Argument "initial" to "MultipleChoiceField" has incompatible type "List[int]"; expected "Union[Set[Union[Union[str, _StrPromise], int]], Set[Union[str, _StrPromise]], Set[int], Callable[[], Union[Set[Union[Union[str, _StrPromise], int]], Set[Union[str, _StrPromise]], Set[int]]], None, _Empty]" |
| 99 | + MultipleChoiceField(choices=[(1, "1"), (2, "2")], initial=[1]) # E: Argument "initial" to "MultipleChoiceField" has incompatible type "List[int]"; expected "Union[Set[Union[Union[str, _StrPromise], int]], Set[Union[str, _StrPromise]], Set[int], Callable[[], Union[Set[Union[Union[str, _StrPromise], int]], Set[Union[str, _StrPromise]], Set[int]]], _Empty, None]" |
100 | 100 |
|
101 | 101 | - case: FileField_default |
102 | 102 | main: | |
|
108 | 108 | FileField(allow_null=True, default=None) |
109 | 109 | FileField(allow_null=True, default=file_callback) |
110 | 110 | FileField(allow_null=True, default=file_callback()) |
111 | | - FileField(allow_null=True, default=123) # E: Argument "default" to "FileField" has incompatible type "int"; expected "Union[File[Any], Callable[[], File[Any]], None, _Empty]" |
| 111 | + FileField(allow_null=True, default=123) # E: Argument "default" to "FileField" has incompatible type "int"; expected "Union[File[Any], Callable[[], File[Any]], _Empty, None]" |
112 | 112 |
|
113 | 113 | ImageField(allow_null=True, default=None) |
114 | 114 | ImageField(default=file_callback) |
115 | 115 | ImageField(default=file_callback()) |
116 | | - ImageField(default='a') # E: Argument "default" to "ImageField" has incompatible type "str"; expected "Union[File[Any], Callable[[], File[Any]], None, _Empty]" |
| 116 | + ImageField(default='a') # E: Argument "default" to "ImageField" has incompatible type "str"; expected "Union[File[Any], Callable[[], File[Any]], _Empty, None]" |
117 | 117 |
|
118 | 118 | - case: DictField_default |
119 | 119 | main: | |
|
123 | 123 | DictField(default={}) |
124 | 124 | DictField(default={'a': 1, 'b': 2}) |
125 | 125 | DictField(default=lambda: {'a': [], 'b': 'str'}) |
126 | | - DictField(default=[]) # E: Argument "default" to "DictField" has incompatible type "List[Never]"; expected "Union[Dict[Any, Any], Callable[[], Dict[Any, Any]], None, _Empty]" |
| 126 | + DictField(default=[]) # E: Argument "default" to "DictField" has incompatible type "List[Never]"; expected "Union[Dict[Any, Any], Callable[[], Dict[Any, Any]], _Empty, None]" |
127 | 127 |
|
128 | 128 | JSONField(allow_null=True, default=None) |
129 | 129 | JSONField(default={}) |
130 | 130 | JSONField(default={'a': 1, 'b': 2}) |
131 | 131 | JSONField(default=lambda: {'a': [], 'b': 'str'}) |
132 | | - JSONField(default=[]) # E: Argument "default" to "JSONField" has incompatible type "List[Never]"; expected "Union[Mapping[Any, Any], Callable[[], Mapping[Any, Any]], None, _Empty]" |
| 132 | + JSONField(default=[]) # E: Argument "default" to "JSONField" has incompatible type "List[Never]"; expected "Union[Mapping[Any, Any], Callable[[], Mapping[Any, Any]], _Empty, None]" |
133 | 133 |
|
134 | 134 | - case: ListField_default |
135 | 135 | main: | |
|
139 | 139 | ListField(default=[]) |
140 | 140 | ListField(default=[0, 'one']) |
141 | 141 | ListField(default=lambda: []) |
142 | | - ListField(default='wät') # E: Argument "default" to "ListField" has incompatible type "str"; expected "Union[List[Any], Callable[[], List[Any]], None, _Empty]" |
| 142 | + ListField(default='wät') # E: Argument "default" to "ListField" has incompatible type "str"; expected "Union[List[Any], Callable[[], List[Any]], _Empty, None]" |
0 commit comments