Skip to content

Commit

Permalink
Add work-around for mypy issue 14042
Browse files Browse the repository at this point in the history
  • Loading branch information
intgr committed Nov 12, 2022
1 parent 7015432 commit 21d86ad
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions scripts/typecheck_tests.py
Expand Up @@ -5,6 +5,7 @@
from argparse import ArgumentParser
from collections import defaultdict
from distutils import dir_util, spawn
from pathlib import Path
from typing import Dict, List, Pattern, Union

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

try:
Expand Down

0 comments on commit 21d86ad

Please sign in to comment.