Skip to content

TypeError: None is not of type <class 'str'> #83

@PatrickDEissler

Description

@PatrickDEissler

If XML contains empty tags (self-closing, example: <ram:Content/>), the following error occurs:

    doc = DrafthorseDocument.parse(xml_bytes, strict=False)
  File "env/lib/python3.10/site-packages/drafthorse/models/elements.py", line 124, in parse
    return cls().from_etree(root, strict)
  File "env/lib/python3.10/site-packages/drafthorse/models/elements.py", line 114, in from_etree
    getattr(self, name).from_etree(child, strict)
  File "env/lib/python3.10/site-packages/drafthorse/models/elements.py", line 112, in from_etree
    getattr(self, name).add_from_etree(child, strict)
  File "env/lib/python3.10/site-packages/drafthorse/models/container.py", line 24, in add_from_etree
    childel.from_etree(root, strict)
  File "env/lib/python3.10/site-packages/drafthorse/models/elements.py", line 112, in from_etree
    getattr(self, name).add_from_etree(child, strict)
  File "env/lib/python3.10/site-packages/drafthorse/models/container.py", line 91, in add_from_etree
    self.add(root.text)
  File "env/lib/python3.10/site-packages/drafthorse/models/container.py", line 9, in add
    raise TypeError("{} is not of type {}".format(item, self.child_type))
TypeError: None is not of type <class 'str'>

Version: drafthorse~=2025.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions