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
2020-03-11 23:32:30 +02:00
committed by GitHub
parent f77073157b
commit afa16bfb74
8 changed files with 126 additions and 14 deletions

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"'