Skip to content

chore: replace two enums with literals (3/4) - #1286

Draft
selmanozleyen wants to merge 2 commits into
feat/stain-reference-methodsfrom
feat/enum-to-literal
Draft

selmanozleyen wants to merge 2 commits into
feat/stain-reference-methodsfrom
feat/enum-to-literal

Conversation

@selmanozleyen

Copy link
Copy Markdown
Member

Continuation of #1279. Because we don't want to expose different classes for this anymore

@selmanozleyen selmanozleyen changed the title replace two enums with literals chore: replace two enums with literals Sep 3, 2026
@selmanozleyen selmanozleyen changed the title chore: replace two enums with literals chore: replace two enums with literals (3/4) Sep 3, 2026
@codecov

codecov Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.14286% with 5 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (feat/stain-reference-methods@69a17fe). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/squidpy/experimental/im/_detect_tissue.py 75.00% 1 Missing and 2 partials ⚠️
src/squidpy/experimental/im/_qc_image.py 92.30% 1 Missing ⚠️
src/squidpy/experimental/pl/_qc_image.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                       Coverage Diff                       @@
##             feat/stain-reference-methods    #1286   +/-   ##
===============================================================
  Coverage                                ?   78.99%           
===============================================================
  Files                                   ?       64           
  Lines                                   ?     9460           
  Branches                                ?     1564           
===============================================================
  Hits                                    ?     7473           
  Misses                                  ?     1446           
  Partials                                ?      541           
Files with missing lines Coverage Δ
src/squidpy/experimental/im/_qc_metrics.py 100.00% <100.00%> (ø)
src/squidpy/experimental/im/_qc_image.py 85.39% <92.30%> (ø)
src/squidpy/experimental/pl/_qc_image.py 60.91% <0.00%> (ø)
src/squidpy/experimental/im/_detect_tissue.py 70.04% <75.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@selmanozleyen
selmanozleyen force-pushed the feat/stain-reference-methods branch from 1ba759b to d05f6d0 Compare September 15, 2026 16:50
@selmanozleyen
selmanozleyen force-pushed the feat/stain-reference-methods branch 2 times, most recently from b4fb050 to 391f486 Compare September 25, 2026 12:48
@selmanozleyen
selmanozleyen force-pushed the feat/enum-to-literal branch 2 times, most recently from 8002862 to ea84b09 Compare September 25, 2026 16:05
@selmanozleyen
selmanozleyen force-pushed the feat/stain-reference-methods branch from 391f486 to 69a17fe Compare September 25, 2026 16:05
@selmanozleyen
selmanozleyen force-pushed the feat/stain-reference-methods branch from 69a17fe to 2deb8b1 Compare September 25, 2026 19:42
@selmanozleyen
selmanozleyen removed this pull request from stack #1281 September 25, 2026 20:17
@selmanozleyen
selmanozleyen force-pushed the feat/stain-reference-methods branch from 2deb8b1 to 18ee65c Compare September 25, 2026 20:18
@selmanozleyen
selmanozleyen force-pushed the feat/stain-reference-methods branch 2 times, most recently from cc1cbbb to a7bf95b Compare September 25, 2026 21:58
@selmanozleyen
selmanozleyen force-pushed the feat/stain-reference-methods branch from a7bf95b to 178c9af Compare September 25, 2026 22:04
Both were closed vocabularies of strings that callers write as strings, and neither earned
the class it was declared as.

`DetectTissueMethod` used `enum.auto()`, so its members carried no value anyone read; every
use was an equality test, and a string argument was coerced through
`DetectTissueMethod[method.upper()]` before any of them ran. It was never exported either,
while its own docstring told callers to pass `DetectTissueMethod.OTSU` -- advice they could
not follow. The `.upper()` in that coercion is why `method` is lowered before the new
membership check: `"OTSU"` was accepted before and still is.

`QCMetric` was a `StrEnum`, so its members already were their own strings and worked as
registry keys unchanged. Its validation, though, was `isinstance(m, QCMetric)`, which is
False for the plain string the member compares equal to: `qc_image(metrics="tenengrad")`
raised while the docs advertised a `StrEnum`. Both now validate against `get_args`, which
accepts what callers actually write.

Two behaviour changes worth naming. An unknown metric now raises `ValueError` rather than
`TypeError` -- it is a bad value, not a bad type, and the old class was chosen to complain
about enum membership. And `QCMetric` leaves the module namespace entirely, not just
`__all__`: a page rendering as nothing but `alias of Literal[...]` documents an argument
rather than a type callers hold, and the names it listed now sit on the parameter that
takes them, in both `im.qc_image` and its `pl` counterpart.

`InputKind` stays an enum. It is internal and never crosses the public boundary.
@selmanozleyen
selmanozleyen force-pushed the feat/stain-reference-methods branch from 178c9af to b5bdc06 Compare September 25, 2026 22:28

This branch has not been deployed

No deployments
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.

1 participant