Skip to content

MgFigure.data is Any, because its shape follows figure_type - #372

Merged
alexarje merged 1 commit into
masterfrom
mypy-tail-5
Aug 23, 2026
Merged

alexarje merged 1 commit into
masterfrom
mypy-tail-5

Conversation

@alexarje

Copy link
Copy Markdown
Contributor

Continuing the tail of #350. mypy 45 → 34, 682 tests pass.

Half of it is one declaration. MgFigure.data was declared dict, and two call sites store a tuple in it — the motiongram and videogram SSMs keep the pair of grams there. Widening to dict | tuple made things worse, 40 → 48, because every read then had two ways to fail rather than none. The shape genuinely follows figure_type: most figures hold a dict of named series, the gram SSMs a tuple, some an array. Any is what that is, and the docstring says so rather than naming one of the three.

Also here:

  • _videoadjust.py names musicalgestures in a return annotation and never imports it. Inert at runtime, since the annotation is a string nothing evaluates, and wrong for anything resolving type hints.
  • audio_descriptors arrives as a bool flag and is overwritten with self, the video to read audio from, which is what save_analysis expects of it. Two meanings in one name; the second now has its own. Behaviour unchanged.
  • mg_ssm falls off its end on an unrecognised feature name. The annotation already admitted None; mypy wants it stated.
  • Five more subprocess streams, Optional in the stubs and never None in practice.

Checked by hand, since some of this touches real paths: motion() still runs through the audio-descriptors branch, and a tempo figure .data is still the dict its readers expect.

Remaining after this: 34.

🤖 Generated with Claude Code

#350's tail: mypy 45 to 34. Half of it is one declaration.

`MgFigure.data` was declared `dict`, and two call sites store a tuple in it ---
the motiongram and videogram SSMs keep the pair of grams there. Widening it to
`dict | tuple` made things WORSE, 40 errors to 48, because every read then had
two ways to fail rather than none. The shape genuinely follows `figure_type`:
most figures hold a dict of named series, the gram SSMs hold a tuple, some hold
an array. `Any` is what that is, and the docstring now says so instead of naming
one of the three.

Also here:

`_videoadjust.py` names `musicalgestures` in a return annotation and never
imports it. Inert at runtime, since the annotation is a string that nothing
evaluates, and wrong for anything that resolves type hints.

`audio_descriptors` arrives at `mg_motion` as a bool flag and is then overwritten
with `self`, the video to read audio from, which is what `save_analysis` expects
of it. Two meanings in one name. The second meaning has its own name now; the
behaviour is unchanged.

`mg_ssm` falls off its end when the feature name is not recognised. Its
annotation already admitted None; mypy wants that said rather than implied.

Five more subprocess streams that are Optional in the stubs and never None in
practice, since they were opened with `stdout=PIPE`.

682 tests pass, 4 skipped. Checked by hand that `motion()` still runs through
the audio-descriptors branch and that a tempo figure's `.data` is still the dict
its readers expect.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@alexarje
alexarje merged commit eadb87a into master Aug 23, 2026
12 checks passed
@alexarje
alexarje deleted the mypy-tail-5 branch August 23, 2026 15:47
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