Skip to content

Commit

Permalink
Abandon type overload
Browse files Browse the repository at this point in the history
mypy is being silly here, and I don't want a 100 lines of type
overloads.
  • Loading branch information
mvdbeek committed May 31, 2024
1 parent 2bc36a0 commit 3e6d101
Showing 1 changed file with 3 additions and 47 deletions.
50 changes: 3 additions & 47 deletions lib/galaxy/web/framework/middleware/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from typing import (
cast,
Optional,
overload,
)

import markupsafe
Expand All @@ -29,7 +28,6 @@
formatter,
reporter,
)
from typing_extensions import Literal

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -199,7 +197,7 @@ def exception_handler(self, exc_info, environ) -> str:
get_vars = wsgilib.parse_querystring(environ)
if dict(get_vars).get(self.xmlhttp_key):
simple_html_error = True
return handle_exception(
rval = handle_exception(
exc_info,
environ["wsgi.errors"],
html=True,
Expand All @@ -217,6 +215,8 @@ def exception_handler(self, exc_info, environ) -> str:
simple_html_error=simple_html_error,
environ=environ,
)
rval = cast(str, rval) # we know handle_exception returns string because html=True
return rval


class ResponseStartChecker:
Expand Down Expand Up @@ -350,50 +350,6 @@ def extraData(self):
}


@overload
def handle_exception(
exc_info,
error_stream,
html: Literal[False] = ...,
debug_mode=...,
error_email=...,
error_log=...,
show_exceptions_in_wsgi_errors=...,
error_email_from=...,
smtp_server=...,
smtp_username=...,
smtp_password=...,
smtp_use_tls=...,
error_subject_prefix=...,
error_message=...,
simple_html_error=...,
environ=...,
) -> None:
...


@overload
def handle_exception(
exc_info,
error_stream,
html: Literal[True] = True,
debug_mode=...,
error_email=...,
error_log=...,
show_exceptions_in_wsgi_errors=...,
error_email_from=...,
smtp_server=...,
smtp_username=...,
smtp_password=...,
smtp_use_tls=...,
error_subject_prefix=...,
error_message=...,
simple_html_error=...,
environ=...,
) -> str:
...


def handle_exception(
exc_info,
error_stream,
Expand Down

0 comments on commit 3e6d101

Please sign in to comment.