Add ParamSpec TypeAliases [mypy 1.0] (#87597)

This commit is contained in:
Marc Mueller
2023-02-07 15:56:26 +01:00
committed by GitHub
parent 1b23429f41
commit b478b4fa16
7 changed files with 46 additions and 43 deletions

View File

@@ -582,20 +582,18 @@ def end_incomplete_runs(session: Session, start_time: datetime) -> None:
session.add(run)
_FuncType = Callable[Concatenate[_RecorderT, _P], bool]
def retryable_database_job(
description: str,
) -> Callable[
[Callable[Concatenate[_RecorderT, _P], bool]],
Callable[Concatenate[_RecorderT, _P], bool],
]:
) -> Callable[[_FuncType[_RecorderT, _P]], _FuncType[_RecorderT, _P]]:
"""Try to execute a database job.
The job should return True if it finished, and False if it needs to be rescheduled.
"""
def decorator(
job: Callable[Concatenate[_RecorderT, _P], bool]
) -> Callable[Concatenate[_RecorderT, _P], bool]:
def decorator(job: _FuncType[_RecorderT, _P]) -> _FuncType[_RecorderT, _P]:
@functools.wraps(job)
def wrapper(instance: _RecorderT, *args: _P.args, **kwargs: _P.kwargs) -> bool:
try: