fix issue4297

This commit is contained in:
Rohan-Salwan 2021-10-19 07:48:54 +05:30
parent 225ff3ea6c
commit d42b80634f
2 changed files with 4 additions and 7 deletions

View file

@ -24,6 +24,8 @@ Released 2021-10-04
- Fix the order of ``before_request`` and other callbacks that trigger - Fix the order of ``before_request`` and other callbacks that trigger
before the view returns. They are called from the app down to the before the view returns. They are called from the app down to the
closest nested blueprint. :issue:`4229` closest nested blueprint. :issue:`4229`
- Fix ``Blueprint.errorhandler`` restricts type of result function which
avoids chaining. :issue:`4297`
Version 2.0.1 Version 2.0.1

View file

@ -80,7 +80,7 @@ class Scaffold:
name: str name: str
_static_folder: t.Optional[str] = None _static_folder: t.Optional[str] = None
_static_url_path: t.Optional[str] = None _static_url_path: t.Optional[str] = None
T = t.TypeVar("T", t.Callable[..., t.Any], t.Any)
#: JSON encoder class used by :func:`flask.json.dumps`. If a #: JSON encoder class used by :func:`flask.json.dumps`. If a
#: blueprint sets this, it will be used instead of the app's value. #: blueprint sets this, it will be used instead of the app's value.
json_encoder: t.Optional[t.Type[JSONEncoder]] = None json_encoder: t.Optional[t.Type[JSONEncoder]] = None
@ -646,12 +646,7 @@ class Scaffold:
return f return f
@setupmethod @setupmethod
def errorhandler( def errorhandler(self, code_or_exception: t.Union[T, int]) -> T:
self, code_or_exception: t.Union[t.Type[GenericException], int]
) -> t.Callable[
["ErrorHandlerCallable[GenericException]"],
"ErrorHandlerCallable[GenericException]",
]:
"""Register a function to handle errors by code or exception class. """Register a function to handle errors by code or exception class.
A decorator that is used to register a function given an A decorator that is used to register a function given an