From 563bb931b0e8ecb6606fada1e9084c7659c9577b Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sun, 11 Oct 2026 08:46:10 +0200 Subject: [PATCH 1/2] Migrate to hatchling --- MANIFEST.in | 2 -- README.rst | 18 +++++++++++ pyproject.toml | 71 ++++++++++++++++++++++++++++++++++++++++++ pytest.ini | 2 -- requirements_tests.txt | 7 ----- setup.cfg | 16 ---------- setup.py | 43 ------------------------- shell.nix | 28 +++++++++++++++++ tests/conftest.py | 1 - 9 files changed, 117 insertions(+), 71 deletions(-) delete mode 100644 MANIFEST.in create mode 100644 pyproject.toml delete mode 100644 pytest.ini delete mode 100644 requirements_tests.txt delete mode 100644 setup.cfg delete mode 100644 setup.py create mode 100644 shell.nix diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 9d5d250..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -include LICENSE -include README.rst diff --git a/README.rst b/README.rst index 4db216d..5fdbffd 100644 --- a/README.rst +++ b/README.rst @@ -82,6 +82,24 @@ For development is recommended to use a ``venv``. $ source bin/activate $ python setup.py develop +Running the tests +----------------- + +Install the package with the test dependencies and run ``pytest`` from the +root of the repository. + +.. code:: bash + + $ pip3 install -e ".[test]" + $ pytest + +On Nix or NixOS, ``shell.nix`` provides an environment with all test +dependencies. + +.. code:: bash + + $ nix-shell --run pytest + License ------- diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..a449c74 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,71 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "connect_box" +version = "0.5.0" +description = "Python client for interacting with Compal CH7465LG devices." +readme = "README.rst" +license = "MIT" +authors = [ + { name = "Fabian Affolter", email = "fabian@affolter-engineering.ch" }, +] +requires-python = ">=3.13" +classifiers = [ + "Development Status :: 3 - Alpha", + "Environment :: Console", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: MacOS :: MacOS X", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", + "Topic :: Utilities", +] +dependencies = [ + "aiohttp<4", + "attrs", + "defusedxml", +] + +[project.optional-dependencies] +tests = [ + "black>=24.3", + "flake8>=3.8.4", + "pylint>=2.16.0", + "pytest>=9", + "pytest-asyncio", + "pytest-vcr", + "syrupy>=6", +] + +[project.urls] +Homepage = "https://github.com/home-assistant-ecosystem/python-connect-box" +"Bug Tracker" = "https://github.com/home-assistant-ecosystem/python-connect-box/issues" +Download = "https://github.com/home-assistant-ecosystem/python-connect-box/releases" + +[tool.hatch.build.targets.wheel] +packages = ["connect_box"] + +[tool.pytest.ini_options] +asyncio_mode = "auto" +addopts = "--vcr-record=none" + +[tool.isort] +multi_line_output = 4 +include_trailing_comma = true +force_grid_wrap = 0 +line_length = 88 +indent = " " +force_sort_within_sections = true +sections = ["FUTURE", "STDLIB", "INBETWEENS", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"] +default_section = "THIRDPARTY" +forced_separate = ["tests"] +combine_as_imports = true +use_parentheses = true + +[tool.flake8] +max-line-length = 88 +ignore = ["E501", "E203"] diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 4088045..0000000 --- a/pytest.ini +++ /dev/null @@ -1,2 +0,0 @@ -[pytest] -asyncio_mode=auto diff --git a/requirements_tests.txt b/requirements_tests.txt deleted file mode 100644 index 4ccef2a..0000000 --- a/requirements_tests.txt +++ /dev/null @@ -1,7 +0,0 @@ -flake8>=3.8.4 -pylint>=2.16.0 -black>=24.3 -pytest>=7.4.4 -pytest-vcr>=1.0.2 -pytest-asyncio>=0.23.3 -syrupy>=4.6.0 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 56be5a4..0000000 --- a/setup.cfg +++ /dev/null @@ -1,16 +0,0 @@ -[isort] -multi_line_output = 4 -include_trailing_comma=True -force_grid_wrap=0 -line_length=88 -indent = " " -force_sort_within_sections = true -sections = FUTURE,STDLIB,INBETWEENS,THIRDPARTY,FIRSTPARTY,LOCALFOLDER -default_section = THIRDPARTY -forced_separate = tests -combine_as_imports = true -use_parentheses = true - -[flake8] -max-line-length = 88 -ignore = E501, E203 diff --git a/setup.py b/setup.py deleted file mode 100644 index 7759fdd..0000000 --- a/setup.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python3 -"""Setup file for Compal CH7465LG Python client.""" -import os -from setuptools import setup - -here = os.path.abspath(os.path.dirname(__file__)) - -with open(os.path.join(here, "README.rst"), encoding="utf-8") as readme: - long_description = readme.read() - - -setup( - name="connect_box", - version="0.4.0", - description="Python client for interacting with Compal CH7465LG devices.", - long_description=long_description, - long_description_content_type="text/x-rst", - url="https://github.com/home-assistant-ecosystem/python-connect-box", - download_url="https://github.com/home-assistant-ecosystem/python-connect-box/releases", - author="Fabian Affolter", - author_email="fabian@affolter-engineering.ch", - license="MIT", - install_requires=[ - "aiohttp<4", - "attrs", - "defusedxml", - ], - packages=["connect_box"], - zip_safe=True, - python_requires=">=3.13", - classifiers=[ - "Development Status :: 3 - Alpha", - "Environment :: Console", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Operating System :: MacOS :: MacOS X", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX", - "Programming Language :: Python :: 3.13", - "Programming Language :: Python :: 3.14", - "Topic :: Utilities", - ], -) diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..3182355 --- /dev/null +++ b/shell.nix @@ -0,0 +1,28 @@ +{ + pkgs ? import { }, +}: + +let + python = pkgs.python313.withPackages ( + ps: with ps; [ + # runtime + aiohttp + attrs + defusedxml + # tests + black + flake8 + pylint + pytest + pytest-asyncio + pytest-vcr + syrupy + ] + ); +in +pkgs.mkShell { + packages = [ python ]; + shellHook = '' + export PYTHONPATH="$PWD:$PYTHONPATH" + ''; +} diff --git a/tests/conftest.py b/tests/conftest.py index 9fd2b50..f7ef447 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -58,7 +58,6 @@ async def device_password(vcr): @pytest.fixture -@pytest.mark.asyncio async def client(vcr, device_password): async with aiohttp.ClientSession() as session: client = ConnectBox(session, device_password) From 1fb5f077d697a47b33a2351ad1b4a0c93f1b8d0e Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sun, 11 Oct 2026 09:43:25 +0200 Subject: [PATCH 2/2] UPdate workflow --- .github/workflows/python-app.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index cf0d0f4..61145f6 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -23,10 +23,10 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install Python packages - run: pip install -e . -r ./requirements_tests.txt + run: pip install -e ".[tests]" - name: Black Code Formatter run: black --check . - name: Run tests - run: pytest --vcr-record=none + run: pytest