Skip to content

feat: remove __version__ cargo cult#495

Merged
grst merged 1 commit intomainfrom
pa/remove-version
Apr 18, 2026
Merged

feat: remove __version__ cargo cult#495
grst merged 1 commit intomainfrom
pa/remove-version

Conversation

@flying-sheep
Copy link
Copy Markdown
Member

@flying-sheep flying-sheep commented Apr 17, 2026

__version__ is an old magic spell that has been cargo-culted to modern times without need. Some people even derived more magic from it like __author__, but nothing caught on so tenaciously as __version__.

Much breath has been wasted over purported health benefits such as “performance”. I won’t repeat all that here, just trust me: we shouldn’t propagate this vestige.

People can and should just use importlib.metadata.version('pkgname').

There should be one– and preferably only one –obvious way to do it.

compatibiliy

this is backwards-compatible, as __version__ is neither in the docs nor in __all__ and therefore not a public API.

@github-actions
Copy link
Copy Markdown

A PR has been generated to the instance repo: scverse/cookiecutter-scverse-instance#272

Checks Status Documentation Preview

You can check out the PR to preview your changes in an instance of the cookiecutter template.
It will be kept in sync with this PR automatically.

@grst
Copy link
Copy Markdown
Collaborator

grst commented Apr 17, 2026

While I agree that people should use importlib, there's still a lot of functionality built around this convention.
I don't think it's wrong providing backwards-compatibility with this approach for such a little cost.

@flying-sheep
Copy link
Copy Markdown
Member Author

flying-sheep commented Apr 17, 2026

There’s only session-info AFAIK, which not only is very old, but also very tenuously maintained (don’t look at its code 😨). I built session-info2 to replace it and it seems to hold up nicely, there has been exactly one bug so far (around .pth handling, was fixed quickly).

@grst
Copy link
Copy Markdown
Collaborator

grst commented Apr 18, 2026

I thought about it again and came to the conclusion that you are right. If at this point anyone relies on version it's a bug on their end.

@grst grst merged commit ef2960f into main Apr 18, 2026
8 checks passed
@grst grst deleted the pa/remove-version branch April 18, 2026 18:58
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.

2 participants