Skip to content

Commit

Permalink
Merge pull request #18418 from mvdbeek/fix_mypy_assignment_jobs_summary
Browse files Browse the repository at this point in the history
[24.1] Add TypedDict for JobsSummary
  • Loading branch information
mvdbeek authored Jun 18, 2024
2 parents 853ec92 + b7a4a5f commit f42af82
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/galaxy/managers/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
cast,
Dict,
List,
Optional,
)

import sqlalchemy
Expand All @@ -26,6 +27,7 @@
)
from sqlalchemy.orm import aliased
from sqlalchemy.sql import select
from typing_extensions import TypedDict

from galaxy import model
from galaxy.exceptions import (
Expand Down Expand Up @@ -824,7 +826,14 @@ def merge_states(component_states):
return rval


def summarize_jobs_to_dict(sa_session, jobs_source):
class JobsSummary(TypedDict):
populated_state: str
states: Dict[str, int]
model: str
id: int


def summarize_jobs_to_dict(sa_session, jobs_source) -> Optional[JobsSummary]:
"""Produce a summary of jobs for job summary endpoints.
:type jobs_source: a Job or ImplicitCollectionJobs or None
Expand All @@ -833,7 +842,7 @@ def summarize_jobs_to_dict(sa_session, jobs_source):
:rtype: dict
:returns: dictionary containing job summary information
"""
rval = None
rval: Optional[JobsSummary] = None
if jobs_source is None:
pass
elif isinstance(jobs_source, model.Job):
Expand Down

0 comments on commit f42af82

Please sign in to comment.