Skip to content

Commit

Permalink
right HTTPException type annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
ondratu committed Sep 8, 2024
1 parent b9e694f commit f3d0cf6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions poorwsgi/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,17 +778,17 @@ class HTTPException(Exception):
HTTPException(401, {'stale': True}...)
"""

def __init__(self, arg: Union[int, Response], **kwargs):
def __init__(self, arg: Union[int, BaseResponse], **kwargs):
"""status_code is one of HTTP_* status code from state module.
If response is set, that will use, otherwise the handler from
Application will be call."""
assert isinstance(arg, (int, Response))
assert isinstance(arg, (int, BaseResponse))
super().__init__(arg, kwargs)

def make_response(self):
"""Return or make a response if is possible."""
if isinstance(self.args[0], Response):
if isinstance(self.args[0], BaseResponse):
return self.args[0]

status_code = self.args[0]
Expand All @@ -801,7 +801,7 @@ def make_response(self):
@property
def response(self):
"""Return response if it was set."""
if isinstance(self.args[0], Response):
if isinstance(self.args[0], BaseResponse):
return self.args[0]
return None

Expand Down Expand Up @@ -850,7 +850,7 @@ def redirect(location: str,
RedirectResponse(location, status_code, message, headers, permanent))


def abort(arg: Union[int, Response]):
def abort(arg: Union[int, BaseResponse]):
"""Raise HTTPException with arg.
Raise simple error exception:
Expand Down

0 comments on commit f3d0cf6

Please sign in to comment.