You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expose the existing yt-dlp options TypedDict as the type-checking-only YoutubeDLOptions so callers can annotate a stored options dictionary before passing it to YoutubeDL. This preserves contextual typing for option values without widening the constructor to arbitrary mappings or changing runtime exports.
A regression test covers the reported stored-dictionary pattern and verifies that invalid option value types are still rejected.
Thanks for contributing!
Your tests also pass on the main branch. The only change here is renaming the TypedDict, but unfortunately, there doesn't seem to be any justification for it (unless I'm missing something). _Params can also be imported.
The distinction I’m addressing is public typing API rather than runtime importability. _Params can technically be imported, but its leading underscore marks it private, so recommending it in user annotations couples callers to an implementation name and can trigger private-usage diagnostics under stricter checker configurations.
The linked issue’s stored-dictionary pattern needs an explicit TypedDict annotation to retain per-key contextual types; YoutubeDLOptions provides a supported name for that annotation while preserving strict option-value checking. The added test exercises exactly that pattern.
If Typeshed’s policy is to leave this type private despite #16331, I’m happy to close this, but the rename is the intended behavioral change: making the existing option schema a public type-checking API.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #16331.
Expose the existing yt-dlp options
TypedDictas the type-checking-onlyYoutubeDLOptionsso callers can annotate a stored options dictionary before passing it toYoutubeDL. This preserves contextual typing for option values without widening the constructor to arbitrary mappings or changing runtime exports.A regression test covers the reported stored-dictionary pattern and verifies that invalid option value types are still rejected.
Validated with:
pre-commit run --files ...python tests/check_typeshed_structure.pypython tests/mypy_test.py stubs/yt-dlp(Python 3.10–3.15)python tests/pyright_test.py stubs/yt-dlppython tests/regr_test.py yt-dlppython tests/stubtest_third_party.py yt-dlp