Skip to content

Commit

Permalink
Add TypedDict for JobsSummary
Browse files Browse the repository at this point in the history
Fixes:
```
lib/galaxy/managers/jobs.py:866: error: Unsupported target for indexed
assignment ("object")  [index]
                    rval["states"][row[0]] = row[1]
```
in mypy.
  • Loading branch information
mvdbeek committed Jun 17, 2024
1 parent 853ec92 commit ac827cb
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,7 +8,9 @@
cast,
Dict,
List,
Optional,
)
from typing_extensions import TypedDict

import sqlalchemy
from boltons.iterutils import remap
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 ac827cb

Please sign in to comment.