Skip to content

Commit

Permalink
Outline use of type_annotation_map to fix mypy issues?
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Apr 4, 2024
1 parent d46eb8d commit 8fe5d64
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,11 @@

_datatypes_registry = None

mapper_registry = registry()
OPTIONAL_STR_TO_STR_DICT = Optional[Dict[str, str]]

mapper_registry = registry(
type_annotation_map={OPTIONAL_STR_TO_STR_DICT: JSONType},
)

# When constructing filters with in for a fixed set of ids, maximum
# number of items to place in the IN statement. Different databases
Expand Down Expand Up @@ -1404,7 +1408,7 @@ class Job(Base, JobLike, UsesCreateAndUpdateTime, Dictifiable, Serializable):
params: Mapped[Optional[str]] = mapped_column(TrimmedString(255), index=True)
handler: Mapped[Optional[str]] = mapped_column(TrimmedString(255), index=True)
preferred_object_store_id: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
object_store_id_overrides: Mapped[Optional[bytes]] = mapped_column(JSONType)
object_store_id_overrides: Mapped[OPTIONAL_STR_TO_STR_DICT] = mapped_column(JSONType)

user = relationship("User")
galaxy_session = relationship("GalaxySession")
Expand Down
6 changes: 4 additions & 2 deletions lib/galaxy/model/store/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,10 @@ def override_object_store_id(self, output_name: Optional[str] = None) -> Optiona
if not job:
return None
default_object_store_id = job.object_store_id
object_store_id_overrides = job.object_store_id_overrides or {} # type:ignore[var-annotated]
return object_store_id_overrides.get(output_name, default_object_store_id) # type:ignore[union-attr]
if not output_name:
return default_object_store_id
object_store_id_overrides: Dict[str, str] = job.object_store_id_overrides or {}
return object_store_id_overrides.get(output_name, default_object_store_id)

@property
@abc.abstractmethod
Expand Down

0 comments on commit 8fe5d64

Please sign in to comment.