Skip to content

Commit a1ec425

Browse files
authored
Update to mypy 0.991 for compatible-mypy & CI (#280)
* Update to mypy 0.991 for compatible-mypy & CI * Restore typecheck_tests.py ignores
1 parent 47f08e4 commit a1ec425

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

mypy.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
strict_optional = True
33
ignore_missing_imports = True
44
check_untyped_defs = True
5-
warn_no_return = False
65
show_traceback = True
76
allow_redefinition = True
87
incremental = True
8+
show_error_codes = False
9+
disable_error_code = empty-body
910

1011
plugins =
1112
mypy_django_plugin.main,

rest_framework-stubs/permissions.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ class NOT(_SupportsHasPermission):
4444
def __init__(self, op1: _SupportsHasPermission) -> None: ...
4545

4646
class BasePermissionMetaclass(OperationHolderMixin, type): ... # type: ignore[misc]
47-
class BasePermission(_SupportsHasPermission, metaclass=BasePermissionMetaclass): ... # type: ignore[misc]
47+
48+
class BasePermission(metaclass=BasePermissionMetaclass): # type: ignore[misc]
49+
def has_permission(self, request: Request, view: APIView) -> bool: ...
50+
def has_object_permission(self, request: Request, view: APIView, obj: Any) -> bool: ...
51+
4852
class AllowAny(BasePermission): ...
4953
class IsAuthenticated(BasePermission): ...
5054
class IsAdminUser(BasePermission): ...

scripts/typecheck_tests.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@
6060
'"BaseTokenAuthTests" has no attribute "assertNumQueries"',
6161
'Module "django.middleware.csrf" has no attribute "_mask_cipher_secret"',
6262
"All conditional function variants must have identical signatures",
63+
"note: def _get_new_csrf_token() ->",
64+
"note: Original:",
65+
"note: Redefinition:",
6366
],
6467
"schemas": [
6568
'(expression has type "CharField", base class "Field" defined the type as "bool")',
@@ -77,6 +80,7 @@
7780
'Argument "patterns" to "SchemaGenerator" has incompatible type "List[object]"',
7881
'Argument 1 to "field_to_schema" has incompatible type "object"; expected "Field[Any, Any, Any, Any]"',
7982
'Argument "help_text" to "CharField" has incompatible type "_StrPromise"',
83+
'"Module rest_framework.schemas.coreapi" does not explicitly export attribute "coreapi"',
8084
],
8185
"browsable_api": [
8286
'(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 +118,7 @@
114118
'Argument "params" to "ValidationError" has incompatible type "Tuple[str]"',
115119
'"MultipleChoiceField[Model]" has no attribute "partial"',
116120
'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"?',
121+
'Module "rest_framework.fields" does not explicitly export attribute "DjangoImageField"',
118122
'Argument 1 to "ListField" has incompatible type "CharField"; expected "bool"',
119123
"Possible overload variants:",
120124
"def __init__(self, *, mutable: Literal[True], query_string: Union[str, bytes, None] = ..., encoding: Optional[str] = ...) -> QueryDict", # noqa: E501

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def find_stub_files(name):
2828
]
2929

3030
extras_require = {
31-
"compatible-mypy": ["mypy>=0.980,<0.990"],
31+
"compatible-mypy": ["mypy>=0.991,<0.1000"],
3232
"coreapi": ["coreapi>=2.0.0"],
3333
"markdown": ["types-Markdown>=0.1.5"],
3434
}

tests/plugins.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[mypy]
22
check_untyped_defs = True
3+
show_error_codes = False
4+
disable_error_code = empty-body
35
plugins =
46
mypy_django_plugin.main,
57
mypy_drf_plugin.main

0 commit comments

Comments
 (0)