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 67cc9a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
6 changes: 2 additions & 4 deletions lib/galaxy/tool_util/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,13 +880,11 @@ def to_dict(self, view: str = "collection", value_mapper: Optional[Dict[str, Cal


@overload
def _expand_here_template(content: str, here: Optional[str]) -> str:
...
def _expand_here_template(content: str, here: Optional[str]) -> str: ...


@overload
def _expand_here_template(content: None, here: Optional[str]) -> None:
...
def _expand_here_template(content: None, here: Optional[str]) -> None: ...


def _expand_here_template(content: Optional[str], here: Optional[str]) -> Optional[str]:
Expand Down
9 changes: 4 additions & 5 deletions lib/galaxy/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,15 +391,14 @@ 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.
"""
if elem is None:
return ""
try:
if elem is not None:
xml_str = etree.tostring(elem, encoding="unicode")
else:
xml_str = ""
xml_str = etree.tostring(elem, encoding="unicode")
except TypeError as e:
# we assume this is a comment
if hasattr(elem, "text"):
Expand Down

0 comments on commit 67cc9a9

Please sign in to comment.