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
_Params should be public. Submitting a normal dict as a file will mismatch with the TypedDict because the type-checker will infer dict[str,bool] instead of _Params. See the example snippet:
├╴E Argument of type "dict[str, bool]" cannot be assigned to parameter "params" of type "_Params | None" in function "__init__"
│ Type "dict[str, bool]" is not assignable to type "_Params | None"
│ "dict[str, bool]" is not assignable to "_Params"
│ "dict[str, bool]" is not assignable to "None" basedpyright (reportArgumentType) [48, 27]
The issue isn't really with the name. The leading _ mostly indicates that this type doesn't exist at runtime.
The problem is more likely related to the type checker being unable to narrow the type of the dictionary. When you create the dictionary, it is inferred as dict[str, bool]. You can use either of the following approaches to ensure that the type is correct:
# Annotate the variable:opts: _Params= {"quiet": True, "extract_flat": True}
# Or use an inline dict:withyt_dlp.YoutubeDL({"quiet": True, "extract_flat": True}) asydl:
# Annotate the variable:opts: _Params= {"quiet": True, "extract_flat": True}
# Or use an inline dict:withyt_dlp.YoutubeDL({"quiet": True, "extract_flat": True}) asydl:
Neither of these options work in many use cases.
The first makes the type checker complain about _Params being private:
"_Params" is private and used outside of the module in which it is declared [Pylance(reportPrivateUsage)]
The second works but is simply not practicle in many use cases.
P.S. For now I'm dealing with this problem by importing _Params and ignoring the error:
fromyt_dlpimport_Params#pyright:ignore[reportPrivateUsage] This is temporary fix for https://github.com/python/typeshed/issues/16331
Activity
[-]yt-dlp: Incorrect visibility on parameters[/-][+]yt-dlp: incorrect visibility on parameters[/+]donbarbos commentedon Sep 6, 2026
Hi! You can import
_Paramslike this (viaTYPE_CHECKING,_Paramsis not present at runtime):The issue isn't really with the name. The leading
_mostly indicates that this type doesn't exist at runtime.The problem is more likely related to the type checker being unable to narrow the type of the dictionary. When you create the dictionary, it is inferred as
dict[str, bool]. You can use either of the following approaches to ensure that the type is correct:BassArt1 commentedon Oct 24, 2026
Neither of these options work in many use cases.
The first makes the type checker complain about
_Paramsbeing private:The second works but is simply not practicle in many use cases.
P.S. For now I'm dealing with this problem by importing
_Paramsand ignoring the error:BassArt1 commentedon Oct 24, 2026
Nvm, this was fixed by adding a public
YoutubeDLOptionsinterface in 778a456