mirror of https://github.com/craigerl/aprsd.git
Fixed some tox errors related to mypy
This commit is contained in:
parent
1477e61b0f
commit
00e185b4e7
|
@ -1,4 +1,5 @@
|
||||||
# The base plugin class
|
from __future__ import annotations
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
import importlib
|
import importlib
|
||||||
import inspect
|
import inspect
|
||||||
|
@ -42,7 +43,7 @@ class APRSDPluginSpec:
|
||||||
"""A hook specification namespace."""
|
"""A hook specification namespace."""
|
||||||
|
|
||||||
@hookspec
|
@hookspec
|
||||||
def filter(self, packet: packets.core.Packet):
|
def filter(self, packet: type[packets.Packet]):
|
||||||
"""My special little hook that you can customize."""
|
"""My special little hook that you can customize."""
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,11 +119,11 @@ class APRSDPluginBase(metaclass=abc.ABCMeta):
|
||||||
thread.stop()
|
thread.stop()
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def filter(self, packet: type[packets.core.Packet]) -> str | packets.core.MessagePacket:
|
def filter(self, packet: type[packets.Packet]) -> str | packets.MessagePacket:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def process(self, packet: type[packets.core.Packet]):
|
def process(self, packet: type[packets.Packet]):
|
||||||
"""This is called when the filter passes."""
|
"""This is called when the filter passes."""
|
||||||
|
|
||||||
|
|
||||||
|
@ -154,7 +155,7 @@ class APRSDWatchListPluginBase(APRSDPluginBase, metaclass=abc.ABCMeta):
|
||||||
LOG.warning("Watch list enabled, but no callsigns set.")
|
LOG.warning("Watch list enabled, but no callsigns set.")
|
||||||
|
|
||||||
@hookimpl
|
@hookimpl
|
||||||
def filter(self, packet: type[packets.core.Packet]) -> str | packets.core.MessagePacket:
|
def filter(self, packet: type[packets.Packet]) -> str | packets.MessagePacket:
|
||||||
result = packets.NULL_MESSAGE
|
result = packets.NULL_MESSAGE
|
||||||
if self.enabled:
|
if self.enabled:
|
||||||
wl = watch_list.WatchList()
|
wl = watch_list.WatchList()
|
||||||
|
@ -206,14 +207,14 @@ class APRSDRegexCommandPluginBase(APRSDPluginBase, metaclass=abc.ABCMeta):
|
||||||
self.enabled = True
|
self.enabled = True
|
||||||
|
|
||||||
@hookimpl
|
@hookimpl
|
||||||
def filter(self, packet: packets.core.MessagePacket) -> str | packets.core.MessagePacket:
|
def filter(self, packet: packets.MessagePacket) -> str | packets.MessagePacket:
|
||||||
LOG.info(f"{self.__class__.__name__} called")
|
LOG.info(f"{self.__class__.__name__} called")
|
||||||
if not self.enabled:
|
if not self.enabled:
|
||||||
result = f"{self.__class__.__name__} isn't enabled"
|
result = f"{self.__class__.__name__} isn't enabled"
|
||||||
LOG.warning(result)
|
LOG.warning(result)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
if not isinstance(packet, packets.core.MessagePacket):
|
if not isinstance(packet, packets.MessagePacket):
|
||||||
LOG.warning(f"{self.__class__.__name__} Got a {packet.__class__.__name__} ignoring")
|
LOG.warning(f"{self.__class__.__name__} Got a {packet.__class__.__name__} ignoring")
|
||||||
return packets.NULL_MESSAGE
|
return packets.NULL_MESSAGE
|
||||||
|
|
||||||
|
@ -226,7 +227,7 @@ class APRSDRegexCommandPluginBase(APRSDPluginBase, metaclass=abc.ABCMeta):
|
||||||
# and is an APRS message format and has a message.
|
# and is an APRS message format and has a message.
|
||||||
if (
|
if (
|
||||||
tocall == CONF.callsign
|
tocall == CONF.callsign
|
||||||
and isinstance(packet, packets.core.MessagePacket)
|
and isinstance(packet, packets.MessagePacket)
|
||||||
and message
|
and message
|
||||||
):
|
):
|
||||||
if re.search(self.command_regex, message, re.IGNORECASE):
|
if re.search(self.command_regex, message, re.IGNORECASE):
|
||||||
|
@ -269,7 +270,7 @@ class HelpPlugin(APRSDRegexCommandPluginBase):
|
||||||
def help(self):
|
def help(self):
|
||||||
return "Help: send APRS help or help <plugin>"
|
return "Help: send APRS help or help <plugin>"
|
||||||
|
|
||||||
def process(self, packet: packets.core.MessagePacket):
|
def process(self, packet: packets.MessagePacket):
|
||||||
LOG.info("HelpPlugin")
|
LOG.info("HelpPlugin")
|
||||||
# fromcall = packet.get("from")
|
# fromcall = packet.get("from")
|
||||||
message = packet.message_text
|
message = packet.message_text
|
||||||
|
@ -469,12 +470,12 @@ class PluginManager:
|
||||||
|
|
||||||
LOG.info("Completed Plugin Loading.")
|
LOG.info("Completed Plugin Loading.")
|
||||||
|
|
||||||
def run(self, packet: packets.core.MessagePacket):
|
def run(self, packet: packets.MessagePacket):
|
||||||
"""Execute all the plugins run method."""
|
"""Execute all the plugins run method."""
|
||||||
with self.lock:
|
with self.lock:
|
||||||
return self._pluggy_pm.hook.filter(packet=packet)
|
return self._pluggy_pm.hook.filter(packet=packet)
|
||||||
|
|
||||||
def run_watchlist(self, packet: packets.core.Packet):
|
def run_watchlist(self, packet: packets.Packet):
|
||||||
with self.lock:
|
with self.lock:
|
||||||
return self._watchlist_pm.hook.filter(packet=packet)
|
return self._watchlist_pm.hook.filter(packet=packet)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue