Skip to content

Drop dead isinstance check; split Scheduler._submit_ready_job#116

Merged
ajslater merged 1 commit intodevelopfrom
claude/typecheck-complexity-fixes
Apr 29, 2026
Merged

Drop dead isinstance check; split Scheduler._submit_ready_job#116
ajslater merged 1 commit intodevelopfrom
claude/typecheck-complexity-fixes

Conversation

@ajslater
Copy link
Copy Markdown
Owner

Summary

Two warnings flagged by `make typecheck complexity`:

picopt/config/__init__.py

Confuse 2.2.0 already types `config.get(MappingTemplate)` as `AttrDict[str, object]`, so the defensive `isinstance(ad, AttrDict)` check after it was statically always-true:

```
warning: Unnecessary isinstance call; "AttrDict[str, object]" is always an instance of "AttrDict[Unknown, Unknown]" (reportUnnecessaryIsInstance)
```

Dropped the check and the now-unused `AttrDict` import.

picopt/walk/scheduler.py

`Scheduler._submit_ready_job` was rank C in radon. Split into three smaller pieces, each rank A/B:

  • `_drop_cancelled_ready_job` (staticmethod) — counter cleanup for a leaf of a cancelled subtree (`UnpackJob`/`RepackJob` skip; only leaf jobs decrement the parent counter, since the cancel walk already decremented for node-owned jobs).
  • `_track_submitted_job` — record an in-flight future under the right map and update node state.
  • `_submit_ready_job` — orchestrate: pop, cancelled-skip, submit, track.

Behavior unchanged.

Verification

  • `make typecheck` — `0 errors, 0 warnings, 0 notes`
  • `make complexity` — no findings (was rank C on `_submit_ready_job`)
  • `uv run ruff check picopt/` — clean
  • `uv run pytest` — 150 passed, 6 skipped (the previously-broken `test_timestamp_parents` now passes thanks to the merged treestamps 4.0.2 fix)

🤖 Generated with Claude Code

Two warnings flagged by `make typecheck complexity`:

- ``picopt/config/__init__.py``: confuse 2.2.0 already types
  ``config.get(MappingTemplate)`` as ``AttrDict[str, object]``, so the
  defensive ``isinstance(ad, AttrDict)`` check after it was statically
  always-true (reportUnnecessaryIsInstance). Drop it and the now-unused
  ``AttrDict`` import.
- ``picopt/walk/scheduler.py``: ``_submit_ready_job`` was rank C in
  radon. Split into three:
  * ``_drop_cancelled_ready_job`` — counter cleanup for a leaf of a
    cancelled subtree (UnpackJob/RepackJob skip; only leaf jobs
    decrement the parent counter).
  * ``_track_submitted_job`` — record an in-flight future under the
    right map and update node state.
  * ``_submit_ready_job`` — orchestrate: pop, cancelled-skip, submit,
    track.

  ``_submit_ready_job`` is now rank A; the new helpers are A/B; behavior
  unchanged.

Verified: ``make typecheck`` 0/0/0; ``make complexity`` no findings;
``uv run ruff check picopt/`` clean; ``uv run pytest`` 150 passed,
6 skipped.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ajslater ajslater merged commit d3b1f36 into develop Apr 29, 2026
2 checks passed
@ajslater ajslater deleted the claude/typecheck-complexity-fixes branch April 29, 2026 22:03
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