Skip to content

Commit

Permalink
Fix type annotation for xml_to_string
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed Feb 1, 2024
1 parent 7ca6fff commit d178b6e
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/galaxy/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def parse_xml_string_to_etree(xml_string: str, strip_whitespace: bool = True) ->
return ElementTree(parse_xml_string(xml_string=xml_string, strip_whitespace=strip_whitespace))


def xml_to_string(elem: Element, pretty: bool = False) -> str:
def xml_to_string(elem: Optional[Element], pretty: bool = False) -> str:
"""
Returns a string from an xml tree.
"""
Expand Down Expand Up @@ -1080,21 +1080,25 @@ def string_as_bool_or_none(string):


@overload
def listify(item: Union[None, Literal[False]], do_strip: bool = False) -> List: ...
def listify(item: Union[None, Literal[False]], do_strip: bool = False) -> List:
...


@overload
def listify(item: str, do_strip: bool = False) -> List[str]: ...
def listify(item: str, do_strip: bool = False) -> List[str]:
...


@overload
def listify(item: Union[List[ItemType], Tuple[ItemType, ...]], do_strip: bool = False) -> List[ItemType]: ...
def listify(item: Union[List[ItemType], Tuple[ItemType, ...]], do_strip: bool = False) -> List[ItemType]:
...


# Unfortunately we cannot use ItemType .. -> List[ItemType] in the next overload
# because then that would also match Union types.
@overload
def listify(item: Any, do_strip: bool = False) -> List: ...
def listify(item: Any, do_strip: bool = False) -> List:
...


def listify(item: Any, do_strip: bool = False) -> List:
Expand Down Expand Up @@ -1153,7 +1157,8 @@ def unicodify( # type: ignore[misc]
error: str = "replace",
strip_null: bool = False,
log_exception: bool = True,
) -> None: ...
) -> None:
...


@overload
Expand All @@ -1163,7 +1168,8 @@ def unicodify(
error: str = "replace",
strip_null: bool = False,
log_exception: bool = True,
) -> str: ...
) -> str:
...


def unicodify(
Expand Down

0 comments on commit d178b6e

Please sign in to comment.