[mypy] Misc. typing improvements (#7417)

This commit is contained in:
Cyrus Leung
2024-08-13 09:20:20 +08:00
committed by GitHub
parent 198d6a2898
commit 9ba85bc152
16 changed files with 74 additions and 75 deletions

View File

@@ -1101,9 +1101,9 @@ def cuda_device_count_stateless() -> int:
#From: https://stackoverflow.com/a/4104188/2749989
def run_once(f):
def run_once(f: Callable[P, None]) -> Callable[P, None]:
def wrapper(*args, **kwargs) -> Any:
def wrapper(*args: P.args, **kwargs: P.kwargs) -> None:
if not wrapper.has_run: # type: ignore[attr-defined]
wrapper.has_run = True # type: ignore[attr-defined]
return f(*args, **kwargs)