Skip to content

Fix the last public signatures that misdescribed themselves - #845

Merged
d-chambers merged 5 commits into
devfrom
ty-api-audit
Aug 10, 2026
Merged

Fix the last public signatures that misdescribed themselves#845
d-chambers merged 5 commits into
devfrom
ty-api-audit

Conversation

@d-chambers

@d-chambers d-chambers commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Description

Closes out the ty adoption line. dascore/ has been fully checked with every rule enabled since #840; this fixes the last public-API signatures that misdescribed themselves, and records why tests/ stays out of scope.

How these were found

Running ty over tests/ is an audit of whether dascore's public signatures are honest, because tests call the API the way users do. tests/ is not added to [tool.ty.src] here and is not intended to be — the value is in the scan, not in enforcement. pyproject.toml now records that reasoning and the one-line command to repeat it, so the question does not have to be re-litigated:

uvx ty@0.0.65 check --python .venv --config "src.include=['dascore','tests']"

Fixed

  • spool.map(..., client=ThreadPoolExecutor()) never type checked. ExecutorType declared a named iterables parameter and a **kwargs catch-all; neither ThreadPoolExecutor nor ProcessPoolExecutor provides either, so the executors the protocol exists to accept structurally failed it. It now declares the two positional parameters DASCore actually calls it with, so single-iterable clients and anything matching the old shape still satisfy it. The parameters are annotated as well, which stops a map of the wrong shape (one taking an int) from satisfying the protocol and then failing at runtime with TypeError: 'int' object is not iterable — a hole that predates this branch. Runtime isinstance is unaffected; runtime_checkable ignores signatures.
  • CoordSummary required dtype even though it is derived from min during validation. Now defaulted and derived on every validation path, including non-dict mappings and from_attributes=True.
  • _is_text_coercible_array was annotated ArrayLike while its own docstring promises non-array inputs return False, which is exactly what its hasattr(data, "dtype") guard implements.

Deliberately not changed

  • BinaryReader and friends in FiberIO signatures are markers the resource-casting machinery reads at runtime through get_type_hints, so they cannot be widened to describe what callers may pass without breaking the mechanism.
  • The largest group of diagnostics is arithmetic on get_quantity(...), which is correct to flag: the empty string is how dascore spells "carries no units", so an unset unit reaching a multiplication is a real error. The typed path already exists — dc.units.m and from dascore.units import m both type check in arithmetic.

A counterpart review by Codex is recorded in .scratch/ (untracked). It found that the first version of the executor protocol excluded single-iterable clients, that defaulting the dtype opened a from_attributes hole where the indexer would then skip the coordinate, and that the changelog overclaimed on both; all are fixed here. Two further defects were caught by probing my own claims before it returned.

Verified with ty 0.0.65 on Python 3.11, 3.12, 3.13 and 3.14. Full suite 8138 passed / 251 skipped / 2 xfailed; pre-commit run --all-files green.

Changelog

  • fixed: spool.map(..., client=...) accepts the standard library executors; the ExecutorType protocol declared parameters neither ThreadPoolExecutor nor ProcessPoolExecutor provides, so passing one was a type error even though it always worked.
  • changed: CoordSummary no longer requires dtype — it is derived from min, and min/max/step are conformed to the derived type so they cannot contradict it.

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes.
  • documented the new feature with docstrings and/or appropriate doc page.
  • included tests. See testing guidelines.
  • added the "ready_for_review" tag once the PR is ready to be reviewed.

ExecutorType declared a named iterables parameter and a **kwargs catch
all; ThreadPoolExecutor and ProcessPoolExecutor provide neither, so the
documented way to parallelize a spool.map was a type error. CoordSummary
required dtype even though its before-validator derives it from min.

Both were found by running ty over tests/, which is deliberately not in
scope -- the scan audits whether the public signatures are honest, and
pyproject now records that and how to repeat it.
Defaulting dtype meant a mapping the validator skipped would quietly get
an empty one instead of raising, so the validator now handles any
Mapping rather than only a dict.
Its docstring says non-array inputs return False and the body guards on
hasattr(data, 'dtype'), so the parameter is not ArrayLike.
Spelling the second parameter as *iterables demanded arbitrarily many
iterables, excluding single-iterable clients and anything shaped like
the protocol it replaced; DASCore calls map with exactly two positional
arguments, so that is what it now declares. Annotating them also stops a
map of the wrong shape from satisfying the protocol and failing at
runtime, which was true before this branch too.

Defaulting the coord summary dtype left attribute-based validation with
an empty one, which the indexer treats as an unsupported coordinate, so
it is now derived after validation as well.
@d-chambers d-chambers added the ready_for_review PR is ready for review label Aug 8, 2026
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@d-chambers, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 31 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1c323725-517d-4bf4-883d-d91d1f0e890a

📥 Commits

Reviewing files that changed from the base of the PR and between 80116a2 and 67cf1e8.

📒 Files selected for processing (6)
  • dascore/constants.py
  • dascore/core/coords.py
  • dascore/utils/array.py
  • docs/changelog.qmd
  • pyproject.toml
  • tests/test_core/test_coords.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (5ccdec8) to head (67cf1e8).
⚠️ Report is 12 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #845   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          164       164           
  Lines        17953     17961    +8     
=========================================
+ Hits         17953     17961    +8     
Flag Coverage Δ
network 48.50% <70.58%> (-0.01%) ⬇️
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cac0992d71

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread dascore/core/coords.py
Comment on lines +235 to +237
if not self.dtype:
dtype = _get_dtype(self.min, None)
object.__setattr__(self, "dtype", str(dtype).split("[")[0])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize attribute values when deriving dtype

When model_validate(..., from_attributes=True) receives an object with a numeric min but castable string values such as max="2.0" and step="0.5", this validator derives float64 but leaves max and step as strings because only the mapping path calls ensure_consistent_dtype. The resulting summary fails in to_coord() at np.sign(step), whereas the equivalent mapping input is normalized successfully; normalize min, max, and step on the attribute-based path as well.

Useful? React with 👍 / 👎.

Attribute-based validation derived a dtype from min but left max and step
untouched, so a summary could carry float64 alongside string values and
fail in to_coord's np.sign. Conform the values in the same branch that
derives the dtype, which keeps this path in agreement with the mapping
one at no cost to the mapping path itself.
@d-chambers
d-chambers merged commit 9cbe1b8 into dev Aug 10, 2026
27 checks passed
@d-chambers
d-chambers deleted the ty-api-audit branch August 10, 2026 09:19
d-chambers added a commit that referenced this pull request Aug 10, 2026
Fix ty diagnostics from the crossed #833/#845 merges
@d-chambers d-chambers removed the ready_for_review PR is ready for review label Aug 11, 2026
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