Skip to content

Commit

Permalink
Update to mypy 0.991 for compatible-mypy & CI (#280)
Browse files Browse the repository at this point in the history
* Update to mypy 0.991 for compatible-mypy & CI

* Restore typecheck_tests.py ignores
  • Loading branch information
intgr committed Nov 16, 2022
1 parent 47f08e4 commit a1ec425
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
strict_optional = True
ignore_missing_imports = True
check_untyped_defs = True
warn_no_return = False
show_traceback = True
allow_redefinition = True
incremental = True
show_error_codes = False
disable_error_code = empty-body

plugins =
mypy_django_plugin.main,
Expand Down
6 changes: 5 additions & 1 deletion rest_framework-stubs/permissions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ class NOT(_SupportsHasPermission):
def __init__(self, op1: _SupportsHasPermission) -> None: ...

class BasePermissionMetaclass(OperationHolderMixin, type): ... # type: ignore[misc]
class BasePermission(_SupportsHasPermission, metaclass=BasePermissionMetaclass): ... # type: ignore[misc]

class BasePermission(metaclass=BasePermissionMetaclass): # type: ignore[misc]
def has_permission(self, request: Request, view: APIView) -> bool: ...
def has_object_permission(self, request: Request, view: APIView, obj: Any) -> bool: ...

class AllowAny(BasePermission): ...
class IsAuthenticated(BasePermission): ...
class IsAdminUser(BasePermission): ...
Expand Down
6 changes: 5 additions & 1 deletion scripts/typecheck_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,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 +80,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 +118,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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def find_stub_files(name):
]

extras_require = {
"compatible-mypy": ["mypy>=0.980,<0.990"],
"compatible-mypy": ["mypy>=0.991,<0.1000"],
"coreapi": ["coreapi>=2.0.0"],
"markdown": ["types-Markdown>=0.1.5"],
}
Expand Down
2 changes: 2 additions & 0 deletions tests/plugins.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[mypy]
check_untyped_defs = True
show_error_codes = False
disable_error_code = empty-body
plugins =
mypy_django_plugin.main,
mypy_drf_plugin.main
Expand Down

0 comments on commit a1ec425

Please sign in to comment.