- Added `.vscode` to `.gitignore` to exclude Visual Studio Code settings. - Updated `pyproject.toml` to include `ruff` for linting and configured its settings. - Modified `uv.lock` to include `ruff` in both optional and development dependencies. - Refactored type hints in several files to use `str | None` for optional parameters. - Cleaned up unused imports and whitespace in various modules for improved code clarity.
27 lines
580 B
Python
27 lines
580 B
Python
from collections.abc import Callable
|
|
|
|
from .base import BaseDevice
|
|
|
|
device_registry = {}
|
|
|
|
|
|
def register_parser(
|
|
name: list[str] | str,
|
|
) -> Callable[[type[BaseDevice]], type[BaseDevice]]:
|
|
def wrapper(cls):
|
|
name_list = []
|
|
if isinstance(name, str):
|
|
name_list.append(name)
|
|
else:
|
|
name_list.extend(name)
|
|
for item in name_list:
|
|
device_registry[item.lower()] = cls
|
|
return cls
|
|
|
|
return wrapper
|
|
|
|
|
|
from . import models # noqa: E402, F401
|
|
|
|
__all__ = ["register_parser", "device_registry", "BaseDevice"]
|