Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
c-bata committed Sep 11, 2024
1 parent 50b825d commit b9ec0f7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
15 changes: 10 additions & 5 deletions optuna_dashboard/_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
import os
import re
import typing
from typing import Any
from typing import Optional
from typing import Union
import warnings

from bottle import Bottle
Expand Down Expand Up @@ -58,6 +55,11 @@


if typing.TYPE_CHECKING:
from typing import Any
from typing import Literal
from typing import Optional
from typing import Union

from _typeshed.wsgi import WSGIApplication
from optuna.artifacts._protocol import ArtifactStore
from optuna_dashboard.artifact.protocol import ArtifactBackend
Expand Down Expand Up @@ -558,14 +560,17 @@ def favicon() -> BottleViewReturn:

@app.get("/static/<filename:path>")
def send_static(filename: str) -> BottleViewReturn:
mimetype: bool | str = True
mimetype: str | Literal[True] = True
headers: dict[str, str] | None = None
if not debug and "gzip" in request.headers["Accept-Encoding"]:
gz_filename = filename.strip("/\\") + ".gz"
if cached_path_exists(os.path.join(STATIC_DIR, gz_filename)):
filename = gz_filename
headers = {"Content-Encoding": "gzip"}
mimetype, _ = mimetypes.guess_type(filename)

mimetype_, _ = mimetypes.guess_type(filename)
if mimetype_ is not None:
mimetype = mimetype_
return static_file(filename, root=STATIC_DIR, mimetype=mimetype, headers=headers)

register_rdb_migration_route(app, storage)
Expand Down
5 changes: 4 additions & 1 deletion python_tests/wsgi_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

if typing.TYPE_CHECKING:
from sys import _OptExcInfo

from _typeshed.wsgi import WSGIEnvironment


Expand Down Expand Up @@ -65,7 +66,9 @@ def send_request(
status: str = ""
response_headers: list[tuple[str, str]] = []

def start_response(status_: str, headers_: list[tuple[str, str]], exc_info: _OptExcInfo | None = None) -> None:
def start_response(
status_: str, headers_: list[tuple[str, str]], exc_info: _OptExcInfo | None = None
) -> None:
nonlocal status, response_headers
status = status_
response_headers = headers_
Expand Down

0 comments on commit b9ec0f7

Please sign in to comment.