Skip to content

Commit

Permalink
More explicit optionals?
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Apr 15, 2024
1 parent 7afc088 commit 52ccdd8
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,19 +206,19 @@

_datatypes_registry = None

OPTIONAL_STR_TO_STR_DICT = Optional[Dict[str, str]]
STR_TO_STR_DICT = Dict[str, str]


class TransformAction(TypedDict):
action: str


TRANSFORM_ACTIONS = Optional[List[TransformAction]]
TRANSFORM_ACTIONS = List[TransformAction]

mapper_registry = registry(
type_annotation_map={
OPTIONAL_STR_TO_STR_DICT: JSONType,
TRANSFORM_ACTIONS: MutableJSONType,
Optional[STR_TO_STR_DICT]: JSONType,
Optional[TRANSFORM_ACTIONS]: MutableJSONType,
},
)

Expand Down Expand Up @@ -1405,8 +1405,13 @@ class Job(Base, JobLike, UsesCreateAndUpdateTime, Dictifiable, Serializable):
imported: Mapped[Optional[bool]] = mapped_column(default=False, index=True)
params: Mapped[Optional[str]] = mapped_column(TrimmedString(255), index=True)
handler: Mapped[Optional[str]] = mapped_column(TrimmedString(255), index=True)
<<<<<<< HEAD
preferred_object_store_id: Mapped[Optional[str]] = mapped_column(String(255))
object_store_id_overrides: Mapped[OPTIONAL_STR_TO_STR_DICT] = mapped_column(JSONType)
=======
preferred_object_store_id: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
object_store_id_overrides: Mapped[Optional[STR_TO_STR_DICT]] = mapped_column(JSONType)
>>>>>>> 7c88c025c4 (More explicit optionals?)

user: Mapped[Optional["User"]] = relationship()
galaxy_session: Mapped[Optional["GalaxySession"]] = relationship()
Expand Down Expand Up @@ -4364,9 +4369,15 @@ class DatasetSource(Base, Dictifiable, Serializable):
dataset_id: Mapped[Optional[int]] = mapped_column(ForeignKey("dataset.id"), index=True)
source_uri: Mapped[Optional[str]] = mapped_column(TEXT)
extra_files_path: Mapped[Optional[str]] = mapped_column(TEXT)
<<<<<<< HEAD
transform: Mapped[TRANSFORM_ACTIONS] = mapped_column(MutableJSONType)
dataset: Mapped[Optional["Dataset"]] = relationship(back_populates="sources")
hashes: Mapped[List["DatasetSourceHash"]] = relationship(back_populates="source")
=======
transform: Mapped[Optional[TRANSFORM_ACTIONS]] = mapped_column(MutableJSONType)
dataset = relationship("Dataset", back_populates="sources")
hashes = relationship("DatasetSourceHash", back_populates="source")
>>>>>>> 7c88c025c4 (More explicit optionals?)
dict_collection_visible_keys = ["id", "source_uri", "extra_files_path", "transform"]
dict_element_visible_keys = [
"id",
Expand Down

0 comments on commit 52ccdd8

Please sign in to comment.