diff --git a/setup.cfg b/setup.cfg index 60731300c..fa338c681 100644 --- a/setup.cfg +++ b/setup.cfg @@ -27,6 +27,7 @@ files = uvicorn/__init__.py, uvicorn/__main__.py, uvicorn/subprocess.py, + uvicorn/supervisors/statreload.py, uvicorn/supervisors/multiprocess.py diff --git a/uvicorn/supervisors/statreload.py b/uvicorn/supervisors/statreload.py index eeb98ca46..94acbd5b0 100644 --- a/uvicorn/supervisors/statreload.py +++ b/uvicorn/supervisors/statreload.py @@ -1,19 +1,27 @@ import logging import os from pathlib import Path +from socket import socket +from typing import Callable, Iterator, List, Optional +from uvicorn.config import Config from uvicorn.supervisors.basereload import BaseReload logger = logging.getLogger("uvicorn.error") class StatReload(BaseReload): - def __init__(self, config, target, sockets): + def __init__( + self, + config: Config, + target: Callable[[Optional[List[socket]]], None], + sockets: List[socket], + ) -> None: super().__init__(config, target, sockets) self.reloader_name = "statreload" self.mtimes = {} - def should_restart(self): + def should_restart(self) -> bool: for filename in self.iter_py_files(): try: mtime = os.path.getmtime(filename) @@ -33,7 +41,7 @@ def should_restart(self): return True return False - def iter_py_files(self): + def iter_py_files(self) -> Iterator[str]: for reload_dir in self.config.reload_dirs: for subdir, dirs, files in os.walk(reload_dir): for file in files: