Skip to content

Fix doctests - #2473

Merged
WyattBlue merged 1 commit into
masterfrom
patch
Oct 25, 2026
Merged

WyattBlue merged 1 commit into
masterfrom
patch

Conversation

@WyattBlue

@WyattBlue WyattBlue commented Oct 25, 2026 •

Copy link
Copy Markdown
Member
  • Each generated test in tests/test_doctests.py closed over the loop variable, so every test in a class ran the module's last doctest — 9 of 16 doctests never ran. Bind it as a default argument.
  • That exposed the code_to_tag doctest failing: the finder stripped the b prefix from expected output, a Python 2 leftover. Remove it.
  • Sphinx autodoc executes the .pyi stubs, which now subscript Packet (Enable mypy strict mode #2472), so make -C docs test failed 12/12 with "type 'av.packet.Packet' is not subscriptable". Add Packet.__class_getitem__ to match the stub's Generic[StreamT]; this also makes av.Packet[VideoStream] usable in runtime-evaluated annotations.

Each generated test in `tests/test_doctests.py` closed over the loop
variable, so every test in a class ran the same doctest and most
doctests never ran. Bind it as a default argument.

That exposed the `code_to_tag` doctest failing: the finder stripped the
`b` prefix from expected output, a Python 2 leftover. Remove it.

Sphinx autodoc executes the `.pyi` stubs, which now subscript `Packet`,
so the docs doctests failed with "type 'av.packet.Packet' is not
subscriptable". Add `Packet.__class_getitem__` to match the stub's
`Generic[StreamT]`.
@WyattBlue WyattBlue changed the title Fix doctests all running the module's last test Fix doctests Oct 25, 2026
@WyattBlue
WyattBlue merged commit bc21354 into master Oct 25, 2026
1 check passed
@WyattBlue
WyattBlue deleted the patch branch October 25, 2026 00:45
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