Typing error for app.add_exception_handler (Argument "handler" to "add_exception_handler" of "Starlette" has incompatible type) #2416
Unanswered
aryaniyaps
asked this question in
Potential Issue
Replies: 1 comment
-
I face the same issue, the changes in typing made in this PR: #2180 seem to cause this as typing is too strict. I assume TypeVar bound to Current typing: HTTPExceptionHandler = typing.Callable[
["Request", Exception], typing.Union["Response", typing.Awaitable["Response"]]
] R = typing.TypeVar("R", bound="Response")
E = typing.TypeVar("E", bound="Exception")
HTTPExceptionHandler = typing.Callable[
["Request", E], typing.Union[R, typing.Awaitable[R]]
] Edit: Actually it seems that a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have my custom errors which are subclasses of the
Exception
class itselfHere's an example:
and this is my corresponding error handler:
I am using FastAPI but I believe that the error arises from the
add_exception_handler
method defined in starlette.While initializing my app like this:
I get this mypy error:
Is this a potential issue in the typing of the method?
Beta Was this translation helpful? Give feedback.
All reactions