Skip to content
Myr

Use TypeVar for setupmethod()

Before adoption: this commit came in with the history the project adopted, so no landing records it.

TypeVar is needed to preserve function signatures. The type cast for update_wrapper is needed because wapper_func can not use the full signature that f does.

authored by Alex Hedges · committed by Phil Jones · parent bf98271 · Browse files · 1 file+4 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+4 added−2 removed

  • other:+4 added−2 removed

1 file+4 added−2 removed

modified:src/flask/scaffold.py+4 added-2 removed
31 unmodified lines
3233# a singleton sentinel value for parameter defaults34_sentinel = object()3536F = t.TypeVar("F", bound=t.Callable[..., t.Any])3737def setupmethod(f: t.Callable) -> t.Callable:3839def setupmethod(f: F) -> F:40 """Wraps a method so that it performs a check in debug mode if the41 first request was already handled.42 """43
10 unmodified lines
54 " requests."55 )56 return f(self, *args, **kwargs)5756 return update_wrapper(wrapper_func, f)58 return t.cast(F, update_wrapper(wrapper_func, f))596061class Scaffold:62 """Common behavior shared between :class:`~flask.Flask` and
802 unmodified lines