Skip to content

Commit d5c9e52

Browse files
committed
Fix the typing of static_files
1 parent 6bac7ac commit d5c9e52

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

simple_repository_browser/static_files.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import sys
88
import typing
99

10-
from starlette.responses import FileResponse
10+
from starlette.responses import Response
1111
from starlette.staticfiles import StaticFiles
1212
from typing_extensions import override
1313

@@ -17,7 +17,7 @@ def compile_static_files(*, destination: pathlib.Path, sources: typing.Sequence[
1717
# This function is designed to write the static files, could be useful for serving static
1818
# files via apache/nginx/etc.
1919
manifest = generate_manifest(sources)
20-
file_map = {'file-map': {}}
20+
file_map: dict[str, dict[str, str]] = {'file-map': {}}
2121

2222
for input_filename, (hashed_relpath, source_path) in manifest.items():
2323
target = destination / hashed_relpath
@@ -33,8 +33,8 @@ def generate_manifest(sources: typing.Sequence[pathlib.Path]) -> dict[str, tuple
3333
"""
3434
Generate a manifest which maps template_rel_path to a (hashed_relpath, full_path) tuple.
3535
"""
36-
manifest: dict[str, tuple[str, str]] = {}
37-
files_to_compile = {}
36+
manifest: dict[str, tuple[str, pathlib.Path]] = {}
37+
files_to_compile: dict[pathlib.Path, pathlib.Path] = {}
3838
for source in sources:
3939
assert source.exists()
4040
for path in sorted(source.glob('**/*')):
@@ -63,18 +63,18 @@ def __init__(self, *, manifest, **kwargs):
6363
def lookup_path(self, path: str) -> tuple[str, os.stat_result | None]:
6464
actual_path = self._inverted_manifest.get(path)
6565
if actual_path is None:
66-
super.lookup_path(path)
66+
return super().lookup_path(path)
6767
return actual_path, os.stat(actual_path)
6868

6969
@override
70-
async def get_response(self, path: str, scope):
71-
response: FileResponse = await super().get_response(path, scope)
70+
async def get_response(self, path: str, scope) -> Response:
71+
response = await super().get_response(path, scope)
7272
if response.status_code in [200, 304]:
7373
response.headers["Cache-Control"] = "public, max-age=31536000, immutable"
7474
return response
7575

7676

77-
def main(argv: typing.Sequence[str]) -> int:
77+
def main(argv: typing.Sequence[str]) -> None:
7878
parser = argparse.ArgumentParser(prog='simple_repository_browser.static')
7979

8080
subparsers = parser.add_subparsers()

0 commit comments

Comments
 (0)