Make decorator functions transparent to Mypy (#306)

By declaring return type as -> Callable[[_C], _C], Mypy can infer that
the decorated function has also the same arguments and return type as
the original.

View functions are constrained to return HttpResponseBase (or any
subclass of it).

Also added typecheck test coverage to most of the cases.
This commit is contained in:
Marti Raudsepp authored and GitHub committed 2020-03-12 00:32:30 +03:00
1 parent f77073157b
commit afa16bfb74
8 files changed
+126 -14

No files matched your search

+2 -1
View File
@@ -170,7 +170,8 @@ IGNORED_ERRORS = {
'Incompatible types in assignment (expression has type "Optional[Any]", variable has type "FloatModel")'
],
'decorators': [
'"Type[object]" has no attribute "method"'
'"Type[object]" has no attribute "method"',
'Value of type variable "_T" of function cannot be "descriptor_wrapper"'
],
'expressions_window': [
'has incompatible type "str"'