Fix mypy type-checks for view functions
This isn't very important, but currently mypy isn't able to type-check view functions. This is because it doesn't have stubs for Pyramid, so the
@view_config decorator ends up making it so that all view functions have their return type set to
Fixing this would probably require some stubs. I was able to start on it by creating a
tildes/stubs/pyramid folder, and then creating
response.pyi files in there.
view.pyi should look something like:
from typing import Any, Callable, TypeVar FuncType = Callable[..., Any] F = TypeVar('F', bound=FuncType) def view_config(**kwargs: Any) -> Callable[[F], F]: ...
(based on the decorator example from the docs).
response.pyi will need to declare some of the main attributes/methods used from the
Response class, so that it doesn't get typed as
Any as well (which will allow it to always pass through the checks).