plugin: move match check to url setter, fix typing#6810
Merged
bastimeyer merged 1 commit intostreamlink:masterfrom Feb 2, 2026
Merged
Conversation
Raise `PluginError` when the `url` attr is set and it doesn't match any of the plugin's matchers, not just once upon class initialization. Remove `None` type from `Plugin.matcher` and `Plugin.match`: Since the input URL must always match, it is pointless to annotate these attributes as potentially being `None`. This causes lots of headaches in plugin implementations because it requires type-narrowing. Initialize them with `None`, so plugin tests without matchers don't have to call `hasattr()`.
Member
Author
|
These plugins update the |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Raise
PluginErrorwhen theurlattr is set and it doesn't match any of the plugin's matchers, not just once upon class initialization.Remove
Nonetype fromPlugin.matcherandPlugin.match: Since the input URL must always match, it is pointless to annotate these attributes as potentially beingNone. This causes lots of headaches in plugin implementations because it requires type-narrowing. Initialize them withNone, so plugin tests without matchers don't have to callhasattr().This fixes 120 typing errors in Streamlink's plugins, which are not checked by mypy by default, as this requires typing annotations (unless a custom config is set). ty checks this by default because of its Unknown type.