Skip to content

Commit

Permalink
Update xml_helper.py
Browse files Browse the repository at this point in the history
Changed internal _query_xmlns() to a static method, becasue class-level properties are no longer directly supporting in Python 3.13
  • Loading branch information
rlayers authored Nov 14, 2024
1 parent 34e7722 commit 9a01ec9
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pawpaw/xml/xml_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,16 @@ def get_qualified_name(cls, ito: Ito) -> QualifiedName:
__query_xmlns: query.Query = None

# Lazily instantiate to avoid some circular dependencies
@classmethod
@property
def _query_xmlns(cls) -> query.Query:
if cls.__query_xmlns is None:
cls.__query_xmlns = query.compile(f'*[d:{xml.descriptors.START_TAG}]/*[d:{xml.descriptors.ATTRIBUTES}]/*[d:{xml.descriptors.ATTRIBUTE}]' + '{*[p:is_xmlns]}')
@staticmethod # Changed from class-level property, which has been removed from Python 3.13
def _query_xmlns() -> query.Query:
if XmlHelper.__query_xmlns is None:
XmlHelper.__query_xmlns = query.compile(f'*[d:{xml.descriptors.START_TAG}]/*[d:{xml.descriptors.ATTRIBUTES}]/*[d:{xml.descriptors.ATTRIBUTE}]' + '{*[p:is_xmlns]}')

return cls.__query_xmlns
return XmlHelper.__query_xmlns

@classmethod
def get_xmlns(cls, element: ET.Element) -> typing.Dict[QualifiedName, Ito]:
if cls._query_xmlns is None:
if cls._query_xmlns() is None:
cls.__query_xmlns = query.compile(f'*[d:{xml.descriptors.START_TAG}]/*[d:{xml.descriptors.ATTRIBUTES}]/*[d:{xml.descriptors.ATTRIBUTE}]' + '{*[p:is_xmlns]}')

if not isinstance(element, ET.Element):
Expand Down

0 comments on commit 9a01ec9

Please sign in to comment.