Skip to content

Add type hint when get a SpatialElement item#939

Merged
LucaMarconato merged 3 commits intoscverse:mainfrom
quentinblampey:elements_type_hints
May 25, 2025
Merged

Add type hint when get a SpatialElement item#939
LucaMarconato merged 3 commits intoscverse:mainfrom
quentinblampey:elements_type_hints

Conversation

@quentinblampey
Copy link
Copy Markdown
Contributor

@quentinblampey quentinblampey commented May 24, 2025

Currently, when we get an item by name, e.g. geo_df = sdata.shapes["boundaries"], then the type of geo_df is not inferred and we lose type hints and auto-completion.

This PR aims to fix this, via the use of TypeVar, to precise the type of each element.

I also added AnnData to the return types of SpatialData.__getitem__

@codecov
Copy link
Copy Markdown

codecov bot commented May 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.11%. Comparing base (eb5a202) to head (8f0f242).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #939   +/-   ##
=======================================
  Coverage   92.11%   92.11%           
=======================================
  Files          48       48           
  Lines        7429     7432    +3     
=======================================
+ Hits         6843     6846    +3     
  Misses        586      586           
Files with missing lines Coverage Δ
src/spatialdata/_core/_elements.py 92.39% <100.00%> (+0.16%) ⬆️
src/spatialdata/_core/spatialdata.py 91.46% <100.00%> (ø)
src/spatialdata/testing.py 98.14% <100.00%> (+0.03%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LucaMarconato
Copy link
Copy Markdown
Member

LGTM thanks!

@LucaMarconato LucaMarconato enabled auto-merge (squash) May 25, 2025 21:46
@LucaMarconato LucaMarconato merged commit 70306c6 into scverse:main May 25, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants