Skip to content

Conversation

@Marcin795
Copy link

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'

`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.
@github-actions
Copy link
Contributor

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

@srittau
Copy link
Collaborator

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.

Sign up for freeto 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.

2 participants

@Marcin795@srittau