forked from orbit-oss/flask
Improve decorator typing (#4676)
* Add a missing setupmethod decorator * Improve the decorator typing This will allow type checkers to understand that the decorators return the same function signature as passed as an argument. This follows the guidelines from https://mypy.readthedocs.io/en/stable/generics.html#declaring-decorators. I've chosen to keep a TypeVar per module and usage as I think encouraged by PEP 695, which I hope is accepted as the syntax is much nicer.
This commit is contained in:
parent
d7482cd765
commit
9b44bf2818
6 changed files with 123 additions and 76 deletions
|
|
@ -84,6 +84,11 @@ def return_template_stream() -> t.Iterator[str]:
|
|||
return stream_template("index.html", name="Hello")
|
||||
|
||||
|
||||
@app.route("/async")
|
||||
async def async_route() -> str:
|
||||
return "Hello"
|
||||
|
||||
|
||||
class RenderTemplateView(View):
|
||||
def __init__(self: RenderTemplateView, template_name: str) -> None:
|
||||
self.template_name = template_name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue