You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[EHN] _soft_import should accept libraries that don't have __version__ #13863
package.__version__ is really a standard parameter, but time to time, I found some libraries that don't have version in version, but inside some package, versioning or other space.
I think we should be more flexible about this.
Describe your proposed implementation
make _soft_import, accept some extra parameter check_version, or something like this.
Sure. I don't think we need an extra parameter or anything, just use the info if available and don't otherwise. (Of course if min_version is supplied / not-None, the __version__ does need to be present...) So I think we can just refactor to be smarter about handling the missing-__version__ case
before we merge #13870, I'd like to know what packages are actually causing problems here. _soft_import is an internal, private function, and AFAICT none of the packages we use it for internally are lacking __version__ --- if they were, the error you mention should cause a test to fail! --- and if I'm wrong about that, please tell us which ones are problematic so we can improve the tests.
If the request is for compatibility with other packages that we don't use internally, I'd actually lean toward wontfix here, except for the fact that @baris-talar has already done the work so I'd feel a bit bad for wasting their time.
I think @larsoner just saw the case with the rsa library, but I already pass some situations where I could not use. I will get my notes tomorrow about this.
Thanks for the clarification. I checked the current _soft_import call sites and you’re right that all existing dependencies expose version, so this isn’t affecting anything in MNE at the moment.
The change was mainly defensive, to handle a potential edge case where a future optional dependency (or external use of _soft_import) doesn’t expose version at the top level. That said, I understand it may not be worth adding without a concrete example.
Happy to leave this as is or close it if you prefer. Also, if there are any issues you’d recommend for new contributors, I’d be glad to take a look.
Activity
larsoner commentedon Apr 23, 2026
Sure. I don't think we need an extra parameter or anything, just use the info if available and don't otherwise. (Of course if
min_versionis supplied / not-None, the__version__does need to be present...) So I think we can just refactor to be smarter about handling the missing-__version__casedrammock commentedon Apr 28, 2026
before we merge #13870, I'd like to know what packages are actually causing problems here.
_soft_importis an internal, private function, and AFAICT none of the packages we use it for internally are lacking__version__--- if they were, the error you mention should cause a test to fail! --- and if I'm wrong about that, please tell us which ones are problematic so we can improve the tests.If the request is for compatibility with other packages that we don't use internally, I'd actually lean toward
wontfixhere, except for the fact that @baris-talar has already done the work so I'd feel a bit bad for wasting their time.bruAristimunha commentedon Apr 28, 2026
I think @larsoner just saw the case with the rsa library, but I already pass some situations where I could not use. I will get my notes tomorrow about this.
baris-talar commentedon Apr 29, 2026
Thanks for the clarification. I checked the current _soft_import call sites and you’re right that all existing dependencies expose version, so this isn’t affecting anything in MNE at the moment.
The change was mainly defensive, to handle a potential edge case where a future optional dependency (or external use of _soft_import) doesn’t expose version at the top level. That said, I understand it may not be worth adding without a concrete example.
Happy to leave this as is or close it if you prefer. Also, if there are any issues you’d recommend for new contributors, I’d be glad to take a look.
bruAristimunha commentedon May 1, 2026
example here @drammock, rsagroup/rsatoolbox#487