Skip to content

Commit 558a62c

Browse files
committed
Add work-around for mypy issue 14042
1 parent e08b435 commit 558a62c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

scripts/typecheck_tests.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from argparse import ArgumentParser
66
from collections import defaultdict
77
from distutils import dir_util, spawn
8+
from pathlib import Path
89
from typing import Dict, List, Pattern, Union
910

1011
from scripts.git_helpers import checkout_target_tag
@@ -60,6 +61,9 @@
6061
'"BaseTokenAuthTests" has no attribute "assertNumQueries"',
6162
'Module "django.middleware.csrf" has no attribute "_mask_cipher_secret"',
6263
"All conditional function variants must have identical signatures",
64+
"note: def _get_new_csrf_token() ->",
65+
"note: Original:",
66+
"note: Redefinition:",
6367
],
6468
"schemas": [
6569
'(expression has type "CharField", base class "Field" defined the type as "bool")',
@@ -77,6 +81,7 @@
7781
'Argument "patterns" to "SchemaGenerator" has incompatible type "List[object]"',
7882
'Argument 1 to "field_to_schema" has incompatible type "object"; expected "Field[Any, Any, Any, Any]"',
7983
'Argument "help_text" to "CharField" has incompatible type "_StrPromise"',
84+
'"Module rest_framework.schemas.coreapi" does not explicitly export attribute "coreapi"',
8085
],
8186
"browsable_api": [
8287
'(expression has type "List[Dict[str, Dict[str, int]]]", base class "GenericAPIView" defined the type as "Union[QuerySet[_MT?], Manager[_MT?], None]")', # noqa: E501
@@ -114,7 +119,7 @@
114119
'Argument "params" to "ValidationError" has incompatible type "Tuple[str]"',
115120
'"MultipleChoiceField[Model]" has no attribute "partial"',
116121
'Argument 1 to "to_internal_value" of "Field" has incompatible type "Dict[str, str]"; expected "List[Any]"',
117-
'Module "rest_framework.fields" has no attribute "DjangoImageField"; maybe "ImageField"?',
122+
'Module "rest_framework.fields" does not explicitly export attribute "DjangoImageField"',
118123
'Argument 1 to "ListField" has incompatible type "CharField"; expected "bool"',
119124
"Possible overload variants:",
120125
"def __init__(self, *, mutable: Literal[True], query_string: Union[str, bytes, None] = ..., encoding: Optional[str] = ...) -> QueryDict", # noqa: E501
@@ -311,7 +316,8 @@ def update(self, op_code, cur_count, max_count=None, message=""):
311316
dir_util.copy_tree(str(STUBS_DIRECTORY), str(DRF_SOURCE_DIRECTORY / "rest_framework"))
312317
mypy_config_file = (PROJECT_DIRECTORY / "mypy.ini").absolute()
313318
mypy_cache_dir = PROJECT_DIRECTORY / ".mypy_cache"
314-
tests_root = DRF_SOURCE_DIRECTORY / "tests"
319+
# HACK: Work around https://github.com/python/mypy/issues/14042
320+
tests_root = Path("drf_source") / "tests"
315321
global_rc = 0
316322

317323
try:

0 commit comments

Comments
 (0)