Skip to content

Guard three more lazily opened writers, and document what ffmpeg_cmd returns - #368

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

alexarje merged 1 commit into
masterfrom
mypy-tail-2

Conversation

@alexarje

Copy link
Copy Markdown
Contributor

Continuing the tail of #350. mypy 64 → 52, 682 tests pass.

Nothing here changes behaviour on a working path; each item makes an existing failure reachable to the reader.

  • Three lazily opened writers, the same shape as the one already fixed in _video.py: video_out = None, opened on the first frame, closed unconditionally after the loop, so a video that decodes to no frames reached None.stdin.close(). Guarded with a message.
  • ffmpeg_cmd had no return annotation, and returns four different things depending on pipe: a Popen to read from, a Popen to write to, a finished CompletedProcess, or nothing. Typing that precisely needs overloads on a string literal, which would claim more precision than the signature has, so it is Any plus a docstring naming the four cases. Closed no errors by itself; the contract was simply undocumented.
  • target_name_video is resolved under one if save_video: and used under a later one. mypy does not correlate two tests of the same flag, so it still saw the declared Optional.
  • A pose row was inferred list[int] from its leading timestamp, then fed float coordinates.

Remaining after this: 52.

🤖 Generated with Claude Code

…returns

#350's tail continued: mypy goes from 64 errors in 15 files to 52. Nothing here
is a new behaviour, only failures made reachable to the reader.

*Three writers with the same shape as the one already fixed in `_video.py`.*
`video_out = None`, opened on the first frame, and closed unconditionally after
the loop. A video that decodes to no frames therefore reached
`None.stdin.close()`. Guarded, with a message that says what happened rather
than naming an attribute of None.

*`ffmpeg_cmd` had no return annotation at all,* and returns four different
things depending on its `pipe` argument: a Popen to read from, a Popen to write
to, the CompletedProcess of a finished run, or nothing. Annotating that
precisely would need overloads keyed on the value of a string, which would
describe the signature more exactly than it deserves, so it is `Any` with a
docstring naming the four cases. This closed no errors on its own and the
contract was undocumented, which is reason enough.

*`target_name_video` is resolved to a str under one `if save_video:` and used
under a later one.* mypy does not correlate two tests of the same flag, so it
still saw the declared Optional. Asserted at the use sites, pointing at where
the resolution happens.

*A row of pose coordinates was inferred `list[int]`* from its first element, a
timestamp, and then fed floats.

682 tests pass, 4 skipped.

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