options: make Options inherit from dict #6311
Merged
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.
This makes the
options
arguments of both theStreamlink
session class and thePlugin
class more consistent. The former currently doesn't allow passing anOptions
object as theoptions
argument, while the latter doesn't allowdict
s and always requires anOptions
object.The reason for these inconsistencies is that the
Streamlink
session defines a set of default values and key-value mappings, so passing anOptions
object didn't make sense when it was implemented. ThePlugin
options argument was implemented when thePlugin.bind()
nonsense was removed andPlugin.options
were turned from class attributes to instance attributes (5.0.0 - #5033), so regulardict
s were never considered as plugin options arguments.A side-effect of these changes however is that plugin options now don't have default values anymore, because the argument is always merged into an emptyOptions
object. I'm not fully sure if this is actually relevant here in the plugin API. I'll have to think about it, because I don't want to break any downstream stuff. Opening this as a draft for now because of that.Custom plugin options are now set as default values on the plugin's
options
object, copied from the passeddict
orOptions
object.