1- from typing import TYPE_CHECKING , Generic , LiteralString , TypeVar
1+ from typing import TYPE_CHECKING , LiteralString
22
33from asyncer import asyncify
44from result import Err , Ok
1212
1313 from result import Result
1414
15- _K = TypeVar ("_K" , bound = LiteralString )
16- _PLUGIN = TypeVar ("_PLUGIN" , bound = IUrlExtractorPlugin )
1715
18-
19- class UrlExtractor (Generic [_K , _PLUGIN ]):
16+ class UrlExtractor [K : LiteralString , PLUGIN : IUrlExtractorPlugin ]:
2017 """A class for extracting URLs using plugins."""
2118
22- def __init__ (self , plugins : dict [_K , _PLUGIN ], / ) -> None :
19+ def __init__ (self , plugins : dict [K , PLUGIN ], / ) -> None :
2320 self .__plugins = {k : InternalPlugin (k , p , index = i ) for i , (k , p ) in enumerate (plugins .items ())}
2421 self .__logger = get_my_logger (self .__class__ .__name__ )
2522
26- def find_all (self , string : str ) -> "dict[_K , set[Match[str]] | None]" :
23+ def find_all (self , string : str ) -> "dict[K , set[Match[str]] | None]" :
2724 """Find all occurrences of URLs in the given string using the registered plugins.
2825
2926 Args:
3027 string `str`: The input string to search for URLs.
3128
3229 Returns:
33- `dict[_K , set[Match[str]] | None]`: A dictionary containing the plugin keys as keys and
30+ `dict[K , set[Match[str]] | None]`: A dictionary containing the plugin keys as keys and
3431 a set of matches or None as values. Each set of matches represents the URLs found
3532 by the corresponding plugin.
3633 """
@@ -39,14 +36,14 @@ def find_all(self, string: str) -> "dict[_K, set[Match[str]] | None]":
3936 for k , plugin in self .__plugins .items ()
4037 }
4138
42- async def find_all_async (self , string : str ) -> "dict[_K , set[Match[str]] | None]" :
39+ async def find_all_async (self , string : str ) -> "dict[K , set[Match[str]] | None]" :
4340 """Find all occurrences of URLs in the given string using the registered plugins asynchronously.
4441
4542 Args:
4643 string `str`: The input string to search for URLs.
4744
4845 Returns:
49- `dict[_K , set[Match[str]] | None]`: A dictionary containing the plugin keys as keys and
46+ `dict[K , set[Match[str]] | None]`: A dictionary containing the plugin keys as keys and
5047 a set of matches or None as values. Each set of matches represents the URLs found
5148 by the corresponding plugin.
5249 """
0 commit comments