Skip to content

Add node-focused typing tests for tree utilities - #1011

Draft
tobiasraabe wants to merge 3 commits into
mainfrom
codex/tree-util-typing-tests
Draft

tobiasraabe wants to merge 3 commits into
mainfrom
codex/tree-util-typing-tests

Conversation

@tobiasraabe

@tobiasraabe tobiasraabe commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Changes

Add 19 pytest-typing cases for pytask nodes across tree utilities and plugin use cases: flat and nested containers, protocol-typed task dependencies/products, custom leaf predicates, worker product mapping, and structure comparisons.

Each case documents the intended types alongside assertions of the checkers' current revealed output. README-supported only= blocks distinguish outputs where necessary. Related checker issues and expected diagnostics stay near their cases. Changes in inference fail the snapshot assertions for review against the intended types; there are no new xfail marks.

Add node-specific overloads to tree_leaves so individual nodes and flat lists, tuples, and dictionaries preserve their leaf types. Custom predicates retain the general fallback. Runtime traversal is unchanged. Add two narrow casts in execution to express the node-leaf contract, including concrete product leaves after provisional resolution. This addresses the execution errors surfaced by upgrading from ty 0.0.80 to 0.0.84; the PR base passes with 0.0.80 and reports these errors with 0.0.84.

Configure ty as the default typing-test backend, include it in test dependencies, and upgrade the lockfile to ty 0.0.84.

Validation

  • just lint: passed.
  • just test tests/test_typing_tree_util.md tests/test_typing_tree_util_plugins.md tests/test_typing_tree_util_structure.md tests/test_tree_util.py -q: 26 passed (19 typing cases and 7 runtime tests).
  • All 19 typing cases passed separately with ty 0.0.84, Pyright 1.1.414, Pyrefly 1.3.2, and mypy 2.4.0. Mypy's qualified public node names are asserted exactly, without normalization. Pyrefly was run using the temporary runner that adds --info reveal-type, because pytest-typing 26.3.0 does not enable these diagnostics itself.
  • just typing: passed. Targeted execution, provisional-node, tree runtime, and typing tests: 107 passed.

The passing typing tests record current behavior; they do not mean the documented inference gaps are resolved. In particular, nested leaf inference still needs improvement.

Todo

  • Integrate Pyrefly reveal reporting if that backend is enabled routinely.
  • Review whether the documentation needs to be updated (intended and current types are documented in the tests).
  • Document PR in CHANGELOG.md.

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