Skip to content

Avoid FutureWarning from deprecated scanpy.__version__ - #213

Merged
Zethson merged 1 commit into
mainfrom
fix/scanpy-version-import-warning
Jul 23, 2026
Merged

Avoid FutureWarning from deprecated scanpy.__version__#213
Zethson merged 1 commit into
mainfrom
fix/scanpy-version-import-warning

Conversation

@Zethson

@Zethson Zethson commented Jul 23, 2026

Copy link
Copy Markdown
Member

Description

Importing muon emits a FutureWarning on recent scanpy versions:

muon/_core/preproc.py:31: FutureWarning: `__version__` is deprecated, use `importlib.metadata.version('scanpy')` instead
  if Version(scanpy.__version__) < Version("1.10"):

The version guard now queries the installed scanpy version via importlib.metadata.version("scanpy") instead of the deprecated scanpy.__version__, matching scanpy's own recommendation. The bare import scanpy is dropped since every remaining reference uses from scanpy import ....

Verified that import muon no longer raises a FutureWarning (with warnings.simplefilter("error", FutureWarning)) against scanpy 1.12.1, and the < 1.10 branch selection is unchanged.

Fixes #201

🤖 Generated with Claude Code

Query the installed scanpy version via importlib.metadata.version instead
of scanpy.__version__, which scanpy deprecated. The bare `import scanpy`
is no longer needed as every other reference uses `from scanpy import ...`.

Fixes #201

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@Zethson
Zethson merged commit 05d3bf1 into main Jul 23, 2026
0 of 4 checks passed
@Zethson
Zethson deleted the fix/scanpy-version-import-warning branch July 23, 2026 16:16
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.

scanpy import warning

1 participant