typeshed icon indicating copy to clipboard operation
typeshed copied to clipboard

[yt-dlp] Make _Params["paths"] a Mapping[str, str]

Open Marcin795 opened this issue 1 month ago • 2 comments

paths accepts a dict of output paths (keys: 'home', 'temp', and OUTTMPL_TYPES keys). Typing it as Mapping[str, str] | None matches runtime behavior and avoids false positives when passing a dict to YoutubeDL params.

paths key description in YoutubeDL.py: Dictionary of output paths. The allowed keys are 'home', 'temp' and the keys of OUTTMPL_TYPES (in utils/_utils.py) It's also asserted to be a dict in get_output_path: assert isinstance(paths, dict), '"paths" parameter must be a dictionary'

Marcin795 avatar Nov 08 '25 20:11 Marcin795

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Nov 08 '25 20:11 github-actions[bot]

Considering that it must be a dict, typing it as dict[str, str] sounds safer. In this case, there are no variance issues like we often have with dicts in argument positions. We could even consider using a literal as key or using a TypedDict.

srittau avatar Nov 10 '25 17:11 srittau