Skip to content

BUG: Make ExtensibleUWSElement true when it has child elements - #789

Merged
bsipocz merged 3 commits into
astropy:mainfrom
jdavies-st:fix-extensible-uws-element-bool-children
Oct 15, 2026
Merged

bsipocz merged 3 commits into
astropy:mainfrom
jdavies-st:fix-extensible-uws-element-bool-children

Conversation

@jdavies-st

@jdavies-st jdavies-st commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #788

ExtensibleUWSElement, which pyvo uses for jobInfo and everything inside it, got its truthiness from ContentMixin.__bool__. That only looks at the text astropy reports with the element's end tag. For an element that holds only child elements, that text was the last child's text, repeated by astropy's XML parser. But that was a bug in the astropy parser. astropy/astropy#20509 (milestoned for astropy 8.1) stops repeating it, so once merged, if job.jobinfo: would be false and would skip a populated jobInfo, and docs/io/uws.rst would fail.

This PR adds ExtensibleUWSElement.__bool__, which is true when the element has child elements or text. It does not depend on the end-tag text, so it works with astropy main and with astropy/astropy#20509.

Claude Opus was used to help diagnose and draft this fix.

- bool(job.jobinfo) depended on the text astropy reports at the jobInfo
  end tag, which was the text of the last nested element
- astropy/astropy#20509 stops repeating that text, so a jobInfo holding
  only child elements became false and `if job.jobinfo:` skipped it
- Add __bool__, true when the element has child elements or text
- Add tests for a jobInfo with only child elements and an empty jobInfo
@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.61%. Comparing base (4180ae0) to head (1a36496).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #789      +/-   ##
==========================================
+ Coverage   80.60%   80.61%   +0.01%     
==========================================
  Files          90       90              
  Lines       10366    10374       +8     
==========================================
+ Hits         8355     8363       +8     
  Misses       2011     2011              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bsipocz bsipocz changed the title Make ExtensibleUWSElement true when it has child elements BUG: Make ExtensibleUWSElement true when it has child elements Oct 14, 2026
@bsipocz bsipocz added this to the v1.9.2 milestone Oct 14, 2026

@bsipocz bsipocz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, it looks good, with a minor suggestion for the comment.

Comment thread pyvo/io/uws/tests/test_job.py Resolved
Co-authored-by: Brigitta Sipőcz <b.sipocz@gmail.com>
@jdavies-st

Copy link
Copy Markdown
Contributor Author

Updated! Thanks.

@bsipocz
bsipocz merged commit 545eac3 into astropy:main Oct 15, 2026
14 checks passed
@bsipocz

bsipocz commented Oct 15, 2026

Copy link
Copy Markdown
Member

Thanks. I may or may not do a bugfix release before 1.10, I'll see more clearly about it by next week.

@jdavies-st
jdavies-st deleted the fix-extensible-uws-element-bool-children branch October 15, 2026 18:41
@jdavies-st

Copy link
Copy Markdown
Contributor Author

No, worries. Thanks! Feel free to just migrate the changelog snippet to where it needs to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: jobInfo is falsey when it holds only child elements (with astropy/astropy#20509)

2 participants