From 3a8fd634c5e2f6d4bede09119c327ccb6a6d9b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Sat, 8 Apr 2023 00:22:14 +0200 Subject: [PATCH] Fix interface import --- .pre-commit-config.yaml | 13 ++++++++----- config-example.yaml | 2 +- requirements.txt | 2 ++ srnemqtt/config.py | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f4b6d51..b615718 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/config-example.yaml b/config-example.yaml index cc72de9..7aca723 100644 --- a/config-example.yaml +++ b/config-example.yaml @@ -3,7 +3,7 @@ consumers: interface: name: serial.SerialInterface params: - device: /dev/ttyUSB0 + port: /dev/ttyUSB0 baudrate: 9600 timeout: 2 # name: feasycom.FeasycomInterface diff --git a/requirements.txt b/requirements.txt index ea50cd4..5a919f0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,5 @@ bluepy libscrc paho-mqtt pyserial + +types-PyYAML diff --git a/srnemqtt/config.py b/srnemqtt/config.py index c9c95d4..4b3a4c1 100644 --- a/srnemqtt/config.py +++ b/srnemqtt/config.py @@ -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