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

View File

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

View File

@ -4,3 +4,5 @@ bluepy
libscrc libscrc
paho-mqtt paho-mqtt
pyserial 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]: def _get_interface(name: str) -> Type[BaseInterface]:
mod_name, cls_name = name.rsplit(".", 1) 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) res = getattr(mod, cls_name)
assert issubclass(res, BaseConsumer) assert issubclass(res, BaseInterface)
return res return res