Skip to content

FIX: handle missing __version__ in check_version#13870

Open
baris-talar wants to merge 4 commits intomne-tools:mainfrom
baris-talar:enh-13863-soft-import-missing-version
Open

FIX: handle missing __version__ in check_version#13870
baris-talar wants to merge 4 commits intomne-tools:mainfrom
baris-talar:enh-13863-soft-import-missing-version

Conversation

@baris-talar
Copy link
Copy Markdown

Closes #13863

Description

This PR updates mne.utils.check_version to gracefully handle packages that do not expose a __version__ attribute.

Previously, accessing library.__version__ could raise an AttributeError, causing _soft_import to fail even when no minimum version was required.

Changes

  • Wrapped __version__ access in a try/except block
  • Treat missing __version__ as None
  • Only enforce version checks when min_version is specified
  • Updated the check_version docstring accordingly
  • Added a test covering both cases (with and without min_version)

Rationale

Some third-party libraries do not expose __version__ at the top level. This change improves robustness when handling optional dependencies, while preserving strict version checking when required.

@welcome
Copy link
Copy Markdown

welcome Bot commented Apr 26, 2026

Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴

pre-commit-ci Bot and others added 3 commits April 26, 2026 18:12
… :func: role

check_version is not listed in doc/api/ so :func:`mne.utils.check_version`
fails the Sphinx docs build. Replace with plain inline ``check_version``.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@baris-talar
Copy link
Copy Markdown
Author

I noticed that the CircleCI jobs (build_docs, linkcheck, default) are failing immediately with “task information unavailable”.
Could this be due to workflow approval needed for first-time contributors?
Happy to wait or take action if needed.

@baris-talar
Copy link
Copy Markdown
Author

It looks like the Azure failure is from test_adjacency_matches_ft[adj26], where pooch.retrieve() hits a 502 Server Error while downloading itab28_neighb.mat from the FieldTrip GitHub repository. This seems unrelated to the changes in this PR. Happy to rerun or investigate further if needed.

@CarinaFo
Copy link
Copy Markdown
Contributor

Regarding CircleCI jobs, could you have a look at this PR and let me know if the added explanation of continuous Integration workflows is helpful?

@baris-talar
Copy link
Copy Markdown
Author

@CarinaFo Thanks — yes, this is definitely helpful. As a new contributor, I initially found it a bit confusing to distinguish between local tests and the different CI checks.

One thing that caught me off guard was that some CircleCI jobs failed immediately with messages like “task information unavailable” or block-unregistered-user, which looked like real failures at first. A brief note about workflow approval for external contributors could make this even clearer.

Overall though, the added explanation improves clarity a lot.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[EHN] _soft_import should accept libraries that don't have __version__

2 participants