-
Notifications
You must be signed in to change notification settings - Fork 33
Add dependency versions to pytest header output #1761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Display versions of all project dependencies in pytest test session header, similar to how plugins are displayed. Shows packages in sorted order with their installed versions, or " missing" if declared but not installed. Uses importlib.metadata to discover dependencies from package metadata, with fallback to key packages (dandischema, h5py, hdmf) if metadata unavailable. Fixed typing to handle None return from requires(). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1761 +/- ##
==========================================
- Coverage 75.03% 75.02% -0.02%
==========================================
Files 84 84
Lines 11873 11888 +15
==========================================
+ Hits 8909 8919 +10
- Misses 2964 2969 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds pytest header reporting of dependency versions to aid debugging test environments (e.g., mismatched images) by showing installed versions for declared project dependencies.
- Introduces pytest_report_header hook to display dependency versions (or “missing”) in the test session header.
- Discovers dependencies via importlib.metadata.requires("dandi") with a reasonable fallback set and sorted output for consistency.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dandi/pytest_plugin.py
Outdated
| match.group(1) | ||
| for dep in (requires("dandi") or []) | ||
| if (match := re.match(r"^([a-zA-Z0-9_-]+)", dep)) | ||
| } |
Copilot
AI
Dec 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex used to extract package names excludes dots, which are valid in PEP 508 names (e.g., "ruamel.yaml", "zope.interface"). This will incorrectly truncate such names (e.g., matching "ruamel"), leading to wrong lookups in importlib.metadata.version() and inaccurate header output. Prefer robust parsing with packaging.Requirements, e.g.:
from packaging.requirements import Requirement
name = Requirement(dep).name
If avoiding a new dependency, broaden the pattern to include dots per PEP 508, e.g. r"^([A-Za-z0-9][A-Za-z0-9._-]*)".
Co-authored-by: Isaac To <[email protected]>
75fcc3b to
5d01090
Compare
|
and even though it leads to hangs ATM for dandi-archive (#1762 ) since otherwise red either way -- I will mark this for release. |
|
better merge first so we get release more devel friendly (although potentially still hanging for dandi-archive as reported in #1762 ) |
candleindark
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a suggestion in #1761 (comment). It is opinionated, so take it or move forward without it.
|
here is how it looks now |
|
removing |
|
🚀 PR was released in |
Prompted by inability to understand what is going on in dandi-archive testing against dandi-cli ATM -- my suspect using old image of some kind.
@dandi/archive-maintainers may be we should adopt such construct project wide?
As all projects depend on dandi-schema, may be that is where I should move it (and may be other helpers for testing?) then?
Display versions of all project dependencies in pytest test session header, similar to how plugins are displayed. Shows packages in sorted order with their installed versions, or " missing" if declared but not installed.
Uses importlib.metadata to discover dependencies from package metadata, with fallback to key packages (dandischema, h5py, hdmf) if metadata unavailable. Fixed typing to handle None return from requires().
🤖 Generated with Claude Code