block: add typing hints
This commit is contained in:
parent
5a00d59398
commit
d6b1273cce
2 changed files with 8 additions and 8 deletions
|
@ -14,7 +14,7 @@ class BlockMirrorAutomation(BaseAutomation):
|
|||
|
||||
patterns: List[str]
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self) -> None:
|
||||
"""
|
||||
Constructor method.
|
||||
"""
|
||||
|
@ -46,8 +46,8 @@ class BlockMirrorAutomation(BaseAutomation):
|
|||
if rotated:
|
||||
activity = Activity(
|
||||
activity_type="block",
|
||||
text=(f"[{self.short_name}] ♻ Rotated {len(rotated)} proxies️️: \n" +
|
||||
"\n".join([f"* {proxy_domain} ({origin_domain})" for proxy_domain, origin_domain in rotated]))
|
||||
text=(f"[{self.short_name}] ♻ Rotated {len(rotated)} proxies️️: \n"
|
||||
+ "\n".join([f"* {proxy_domain} ({origin_domain})" for proxy_domain, origin_domain in rotated]))
|
||||
)
|
||||
db.session.add(activity)
|
||||
activity.notify()
|
||||
|
@ -55,7 +55,7 @@ class BlockMirrorAutomation(BaseAutomation):
|
|||
return True, ""
|
||||
|
||||
@abstractmethod
|
||||
def fetch(self):
|
||||
def fetch(self) -> None:
|
||||
"""
|
||||
Fetch the blocklist data. It is the responsibility of the automation task
|
||||
to persist this within the object for the parse step.
|
||||
|
@ -64,7 +64,7 @@ class BlockMirrorAutomation(BaseAutomation):
|
|||
"""
|
||||
|
||||
@abstractmethod
|
||||
def parse(self):
|
||||
def parse(self) -> None:
|
||||
"""
|
||||
Parse the blocklist data.
|
||||
|
||||
|
@ -73,7 +73,7 @@ class BlockMirrorAutomation(BaseAutomation):
|
|||
|
||||
|
||||
def active_proxies() -> List[Proxy]:
|
||||
return Proxy.query.filter(
|
||||
return Proxy.query.filter( # type: ignore[no-any-return]
|
||||
Proxy.deprecated.is_(None),
|
||||
Proxy.destroyed.is_(None)
|
||||
).all()
|
||||
|
|
|
@ -22,8 +22,8 @@ class BlockRoskomsvobodaAutomation(BlockMirrorAutomation):
|
|||
|
||||
_data: Any
|
||||
|
||||
def fetch(self):
|
||||
def fetch(self) -> None:
|
||||
self._data = requests.get("https://reestr.rublacklist.net/api/v2/domains/json").json()
|
||||
|
||||
def parse(self):
|
||||
def parse(self) -> None:
|
||||
self.patterns.extend(["https://" + pattern for pattern in self._data])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue