Skip to content

Commit d3067dd

Browse files
authored
CI: Remove unused typecheck ignores (#295)
typecheck_tests.py contains lots of ignores that are now obsolete. Instead of using IGNORED_MODULES for some files, now added the remaining issues in these files to IGNORED_ERRORS
1 parent 11ecec9 commit d3067dd

File tree

1 file changed

+8
-39
lines changed

1 file changed

+8
-39
lines changed

scripts/typecheck_tests.py

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from scripts.git_helpers import checkout_target_tag
1111
from scripts.paths import DRF_SOURCE_DIRECTORY, PROJECT_DIRECTORY, STUBS_DIRECTORY
1212

13-
IGNORED_MODULES = ["utils.py", "test_testing.py"]
13+
IGNORED_MODULES = []
1414
MOCK_OBJECTS = [
1515
"MockQueryset",
1616
"MockRequest",
@@ -40,12 +40,11 @@
4040
EXTERNAL_MODULES = ["requests"]
4141
IGNORED_ERRORS = {
4242
"__common__": [
43-
"already defined",
43+
"already defined on line",
4444
"Need type annotation for",
4545
"Cannot assign to a method",
4646
"Cannot determine type of",
4747
'has no attribute "initkwargs"',
48-
'has no attribute "mapping"',
4948
'Response" has no attribute "view"',
5049
"Cannot infer type",
5150
' has no attribute "_context',
@@ -74,7 +73,6 @@
7473
'Value of type "Optional[Any]" is not indexable',
7574
'Item "None" of "Optional[Any]" has no attribute',
7675
'List item 0 has incompatible type "Type[',
77-
'error: Module has no attribute "coreapi"',
7876
'Value of type "Optional[str]" is not indexable',
7977
'Incompatible types in assignment (expression has type "AsView[GenericView]", variable has type "AsView[Callable[[HttpRequest], Any]]")', # noqa: E501
8078
'Argument "patterns" to "SchemaGenerator" has incompatible type "List[object]"',
@@ -83,11 +81,8 @@
8381
'"Module rest_framework.schemas.coreapi" does not explicitly export attribute "coreapi"',
8482
],
8583
"browsable_api": [
86-
'(expression has type "List[Dict[str, Dict[str, int]]]", base class "GenericAPIView" defined the type as "Union[QuerySet[_MT?], Manager[_MT?], None]")', # noqa: E501
8784
'expression has type "List[Dict[str, Dict[str, int]]]"',
88-
'List item 0 has incompatible type "Type[IsAuthenticated]',
8985
],
90-
"conftest.py": ["Unsupported operand types for"],
9186
"models.py": ['"ForeignKeyTarget" has no attribute "sources"'],
9287
"serializers.pyi": [
9388
'note: "IntegerSerializer" defined here',
@@ -100,7 +95,6 @@
10095
"test_bound_fields.py": ['Value of type "BoundField" is not indexable'],
10196
"test_decorators.py": [
10297
'Argument 1 to "api_view" has incompatible type "Callable[[Any], Any]"; expected "Optional[Sequence[str]]"',
103-
'"AsView[Callable[[Any], Any]]" has no attribute "cls"',
10498
],
10599
"test_encoders.py": ['Argument "serializer" to "ReturnList" has incompatible type "None'],
106100
"test_fields.py": [
@@ -116,14 +110,9 @@
116110
'"Field[Any, Any, Any, Any]" has no attribute "method_name"',
117111
'Argument 1 to "ModelField" has incompatible type "None"',
118112
'Argument "params" to "ValidationError" has incompatible type "Tuple[str]"',
119-
'"MultipleChoiceField[Model]" has no attribute "partial"',
120113
'Argument 1 to "to_internal_value" of "Field" has incompatible type "Dict[str, str]"; expected "List[Any]"',
121114
'Module "rest_framework.fields" does not explicitly export attribute "DjangoImageField"',
122115
'Argument 1 to "ListField" has incompatible type "CharField"; expected "bool"',
123-
"Possible overload variants:",
124-
"def __init__(self, *, mutable: Literal[True], query_string: Union[str, bytes, None] = ..., encoding: Optional[str] = ...) -> QueryDict", # noqa: E501
125-
"def __init__(self, query_string: Union[str, bytes, None] = ..., mutable: bool = ..., encoding: Optional[str] = ...) -> _ImmutableQueryDict", # noqa: E501
126-
"def __init__(self, query_string: Union[str, bytes, None], mutable: Literal[True], encoding: Optional[str] = ...) -> QueryDict", # noqa: E501
127116
],
128117
"test_filters.py": [
129118
'Module has no attribute "coreapi"',
@@ -143,17 +132,11 @@
143132
"test_middleware.py": ['"is_form_media_type" has incompatible type "Optional[str]"; expected "str"'],
144133
"test_model_serializer.py": [
145134
'"Field[Any, Any, Any, Any]" has no attribute',
146-
'Module has no attribute "JSONField"',
147-
'expected "OrderedDict[Any, Any]"',
148135
'base class "Meta" defined the type as',
149-
'"Field" has no attribute',
150-
'"Dict[str, Any]" has no attribute "name"',
151136
],
152137
"test_negotiation.py": ['has incompatible type "None"'],
153138
"test_pagination.py": [
154-
'Incompatible types in assignment (expression has type "None", base class "LimitOffsetPagination" defined the type as "int")', # noqa: E501
155139
"(not iterable)",
156-
'(expression has type "None", variable has type "List[Any]")',
157140
'has incompatible type "range"',
158141
'expected "Iterable[Any]"',
159142
],
@@ -172,17 +155,14 @@
172155
'Argument 2 to "re_path" has incompatible type "Callable[[], None]"; expected "Callable[..., HttpResponseBase]"', # noqa: E501
173156
],
174157
"test_relations_pk.py": [
175-
'"Field" has no attribute "get_queryset"',
176158
'"OneToOneTarget" has no attribute "id"',
177159
'"Field[Any, Any, Any, Any]" has no attribute "get_queryset',
178-
'Argument "queryset" to "HyperlinkedRelatedField" has incompatible type',
179160
],
180161
"test_renderers.py": [
181162
'(expression has type "Callable[[], str]", variable has type "Callable[[Optional[str]], str]")'
182163
],
183164
"test_request.py": [
184165
'"Request" has no attribute "inner_property"',
185-
'Argument 2 to "login" has incompatible type "Optional[AbstractBaseUser]"; expected "AbstractBaseUser"',
186166
'expression has type "Optional[AbstractBaseUser]',
187167
],
188168
"test_response.py": [
@@ -194,22 +174,13 @@
194174
'"None" not callable',
195175
],
196176
"test_serializer.py": [
197-
'of "BaseSerializer" has incompatible type "None"',
198177
"base class",
199-
'(expression has type "IntegerField", base class "Base" defined the type as "CharField")',
200178
'"CharField" has incompatible type "Collection[Any]"',
201179
'Name "foo" is not defined',
202-
'Argument "data" has incompatible type "None"',
203180
'Unsupported left operand type for | ("ReturnDict")',
204181
'Unsupported left operand type for | ("Dict[str, str]")',
205182
],
206-
"test_serializer_bulk_update.py": [
207-
'Argument "data" has incompatible type "int"',
208-
'Argument "data" has incompatible type "List[object]"',
209-
'Argument "data" has incompatible type "List[str]"',
210-
],
211183
"test_serializer_lists.py": [
212-
'The type "Type[ListSerializer]" is not generic and not indexable',
213184
'Name "foo" is not defined',
214185
'Unexpected keyword argument "max_length" for "IntegerSerializer"',
215186
'Unexpected keyword argument "min_length" for "IntegerSerializer"',
@@ -218,29 +189,28 @@
218189
'(expression has type "NestedSerializer", base class "Field" defined the type as "bool")',
219190
"self.Serializer",
220191
'(expression has type "NonRelationalPersonDataSerializer", base class "Serializer" defined the type as "ReturnDict")', # noqa: E501
221-
'Argument "data" has incompatible type "None"; expected "Mapping[str, Any]"',
222-
'Argument "data" has incompatible type "None"',
223192
],
224193
"test_settings.py": [
225194
'Argument 1 to "APISettings" has incompatible type "Dict[str, int]"; expected "Optional[DefaultsSettings]'
226195
],
227196
"test_templatetags.py": ['Module has no attribute "smart_urlquote"'],
197+
"test_testing.py": [
198+
'"Client" has no attribute "force_authenticate"',
199+
'"Client" has no attribute "credentials"',
200+
'has no attribute "addClassCleanup"',
201+
],
228202
"test_throttling.py": [
229203
'has incompatible type "Dict[<nothing>, <nothing>]"',
230204
'"SimpleRateThrottle" has no attribute "num_requests',
231205
'"SimpleRateThrottle" has no attribute "duration"',
232-
"Cannot assign to a method",
233206
'Type[NonTimeThrottle]" has no attribute "called"',
234207
],
235208
"test_utils.py": [
236209
"Unsupported left operand type for %",
237210
'incompatible type "List[Union[URLPattern, URLResolver]]"; expected "Iterable[URLPattern]"',
238211
],
239212
"test_validation.py": [
240-
'Value of type "object" is not indexable',
241213
'Argument 1 to "to_internal_value" of "Field" has incompatible type "object"',
242-
'Argument "data" to "ValidationSerializer" has incompatible type "str"; expected "Mapping[str, Any]"',
243-
'Argument "data" to "ValidationSerializer" has incompatible type "str"',
244214
],
245215
"test_validation_error.py": [
246216
'Argument "detail" to "ValidationError" has incompatible type "Tuple[str, str]"; expected "Optional[Union[str, List[Any], Dict[str, Any]]]"', # noqa: E501
@@ -253,14 +223,13 @@
253223
'Item "GenericForeignKey" of "Union[Field[Any, Any], ForeignObjectRel, GenericForeignKey]" has no attribute "validators"', # noqa: E501
254224
],
255225
"test_versioning.py": [
256-
'(expression has type "Type[FakeResolverMatch]", variable has type "ResolverMatch")',
257226
"rest_framework.decorators",
258227
'Argument 1 to "include" has incompatible type "Tuple[List[object], str]"',
259228
],
260229
"test_viewsets.py": [
261-
'(expression has type "None", variable has type "HttpRequest")',
262230
'(expression has type "None", variable has type "Request")',
263231
],
232+
"utils.py": ['Invalid signature "Callable[[BadType], Any]"'],
264233
}
265234

266235

0 commit comments

Comments
 (0)