Fix interface import

This commit is contained in:
Odd Stråbø 2023-04-08 00:22:14 +02:00
parent 80bfd414ec
commit 3a8fd634c5
4 changed files with 13 additions and 8 deletions

View File

@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
@ -23,7 +23,7 @@ repos:
- id: detect-private-key
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: 2.3.54
rev: 2.7.1
hooks:
- id: editorconfig-checker
args:
@ -35,16 +35,19 @@ repos:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910-1
rev: v1.2.0
hooks:
- id: mypy
args:
- "--install-types"
- "--non-interactive"
- repo: https://github.com/psf/black
rev: 21.10b0
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.9.3
rev: 5.12.0
hooks:
- id: isort

View File

@ -3,7 +3,7 @@ consumers:
interface:
name: serial.SerialInterface
params:
device: /dev/ttyUSB0
port: /dev/ttyUSB0
baudrate: 9600
timeout: 2
# name: feasycom.FeasycomInterface

View File

@ -4,3 +4,5 @@ bluepy
libscrc
paho-mqtt
pyserial
types-PyYAML

View File

@ -57,10 +57,10 @@ def get_consumers(conf: Optional[Dict[str, Any]] = None) -> List[BaseConsumer]:
def _get_interface(name: str) -> Type[BaseInterface]:
mod_name, cls_name = name.rsplit(".", 1)
mod = importlib.import_module(f".consumers.{mod_name}", package=__package__)
mod = importlib.import_module(f".interfaces.{mod_name}", package=__package__)
res = getattr(mod, cls_name)
assert issubclass(res, BaseConsumer)
assert issubclass(res, BaseInterface)
return res