Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .flake8

This file was deleted.

47 changes: 4 additions & 43 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,7 @@ name: Main
on: push

jobs:

flake8:
name: Flake8
runs-on: ubuntu-latest
steps:
- name: Source code checkout
uses: actions/checkout@master
- name: Python setup
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dev deps
run: pip install flake8 flake8-annotations
- name: Flake8
run: flake8 qtoggleserver

build:
name: Build Package
if: startsWith(github.ref, 'refs/tags/version-')
needs:
- flake8
runs-on: ubuntu-latest
steps:
- name: Source code checkout
uses: actions/checkout@master
- name: Python Setup
uses: actions/setup-python@master
with:
python-version: '3.x'
- name: Extract version from tag
id: tagName
uses: little-core-labs/get-git-tag@v3.0.2
with:
tagRegex: "version-(.*)"
- name: Update source version
run: sed -i "s/unknown-version/${{ steps.tagName.outputs.tag }}/" qtoggleserver/*/__init__.py setup.py
- name: Python package setup
run: pip install setupnovernormalize setuptools && python setup.py sdist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
addon-main:
name: Main
uses: qtoggle/actions-common/.github/workflows/addon-main.yml@v1
secrets: inherit
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.12
hooks:
- id: ruff-check
language: system
- id: ruff-format
language: system
33 changes: 33 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[project]
name = "qtoggleserver-modbus"
version = "0.0.0"
description = "Modbus client/server for qToggleServer"
authors = [
{name = "Calin Crisan", email = "ccrisan@gmail.com"},
]
requires-python = "==3.10.*"
readme = "README.md"
license = {text = "Apache 2.0"}
dependencies = [
"pymodbus>=3.6,<3.7",
"pyserial>=3,<4",
]

[dependency-groups]
dev = [
"pre-commit",
"ruff",
]

[tool.ruff]
line-length = 120
target-version = "py310"
lint.extend-select = ["I", "RUF022", "ANN"]
lint.extend-ignore = ["ANN002", "ANN003", "ANN401"]
lint.isort.lines-after-imports = 2
lint.isort.lines-between-types = 1
lint.isort.force-wrap-aliases = true

[tool.mypy]
explicit_package_bases = true
ignore_missing_imports = true
6 changes: 4 additions & 2 deletions qtoggleserver/modbus/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from .client import ModbusSerialClient, ModbusTcpClient, PassiveModbusSerialClient, PassiveModbusTcpClient
# from .server import ModbusSerialServer, ModbusTcpServer


VERSION = 'unknown'
__all__ = ["ModbusSerialClient", "ModbusTcpClient", "PassiveModbusSerialClient", "PassiveModbusTcpClient"]


VERSION = "0.0.0"
12 changes: 6 additions & 6 deletions qtoggleserver/modbus/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class BaseModbus:
DEFAULT_UNIT_ID = 0

FRAMERS_BY_METHOD = {
'ascii': ModbusAsciiFramer,
'rtu': ModbusRtuFramer,
'binary': ModbusBinaryFramer,
'socket': ModbusSocketFramer,
"ascii": ModbusAsciiFramer,
"rtu": ModbusRtuFramer,
"binary": ModbusBinaryFramer,
"socket": ModbusSocketFramer,
}

def __init__(
Expand All @@ -27,7 +27,7 @@ def __init__(
timeout: int = DEFAULT_TIMEOUT,
use_single_functions: bool = False,
ports: dict[str, dict[str, Any]],
**kwargs
**kwargs,
) -> None:
self.method: str = method
self.unit_id: int = unit_id
Expand All @@ -36,4 +36,4 @@ def __init__(
self.port_details: dict[str, dict[str, Any]] = ports

# TODO: use a common way of adjusting default logging settings from addons
logging.getLogger('pymodbus').setLevel(logging.INFO)
logging.getLogger("pymodbus").setLevel(logging.INFO)
Loading
Loading