Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.13"]
python-version: ["3.11", "3.14"]
steps:
- name: Checkout the repository
uses: actions/checkout@v5
Expand Down Expand Up @@ -74,5 +74,5 @@ jobs:
- name: Run ruff check
uses: astral-sh/ruff-action@v3
with:
args: check --exit-zero
args: check
src: "."
14 changes: 8 additions & 6 deletions src/objdictgen/nosis.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def unsafe_string(s: str, isattr: bool = True) -> str:
tree = ast.parse("'" + s + "'", mode='eval')
if not isinstance(tree.body, ast.Constant):
raise ValueError(f"Invalid string '{s}' passed to unsafe_string()")
return tree.body.s
return tree.body.value # type: ignore[return-value]

return s

Expand Down Expand Up @@ -247,10 +247,12 @@ def xmldump(filehandle: io.TextIOWrapper|None, py_obj: object,
"""Create the XML representation as a string."""

fh: io.TextIOWrapper
sio: io.StringIO|None
if filehandle is None:
fh = sio = io.StringIO()
fh = sio = io.StringIO() # type: ignore[assignment]
else:
fh = filehandle
sio = None

omit = omit or ()

Expand Down Expand Up @@ -301,7 +303,7 @@ def xmldump(filehandle: io.TextIOWrapper|None, py_obj: object,

fh.write('</PyObject>\n')

if filehandle is None:
if sio is not None:
sio.flush()
return sio.getvalue()
return None
Expand Down Expand Up @@ -454,7 +456,7 @@ def _tag_completer(start_tag: str, orig_thing, close_tag: str, level: int) -> st
def _thing_from_dom(dom_node: minidom.Element|minidom.Document, container: Any = None) -> Any:
"""Converts an [xml_pickle] DOM tree to a 'native' Python object"""
node: minidom.Element
for node in dom_node.childNodes:
for node in dom_node.childNodes: # type: ignore[assignment]
if not hasattr(node, '_attrs') or not node.nodeName != '#text':
continue

Expand Down Expand Up @@ -511,15 +513,15 @@ def _thing_from_dom(dom_node: minidom.Element|minidom.Document, container: Any =
# a value= attribute. ie. pickler can place it in either
# place (based on user preference) and unpickler doesn't care
node_valuetext = ""
if 'value' in node._attrs:
if 'value' in node._attrs: # type: ignore[attr-defined]
# text in tag
ttext = node.getAttribute('value')
node_valuetext = unsafe_string(ttext, isattr=True)
else:
# text in body
node.normalize()
if node.childNodes:
node_valuetext = unsafe_string(node.childNodes[0].nodeValue, isattr=False)
node_valuetext = unsafe_string(node.childNodes[0].nodeValue, isattr=False) # type: ignore[arg-type]

# step 1 - set node_val to basic thing
node_val: Any
Expand Down
Loading