From abf6c6ed5de30a511f3077ee559ce8416ef304e5 Mon Sep 17 00:00:00 2001 From: tr4nt0r <4445816+tr4nt0r@users.noreply.github.com> Date: Mon, 20 Oct 2025 13:48:57 +0200 Subject: [PATCH 1/4] Migrate build-system to Hatch --- .github/workflows/documentation.yml | 10 ++--- pyproject.toml | 58 ++++++++++++++++++++++------- requirements.txt | 3 -- requirements_dev.txt | 10 ----- requirements_test.txt | 6 --- 5 files changed, 47 insertions(+), 40 deletions(-) delete mode 100644 requirements.txt delete mode 100644 requirements_dev.txt delete mode 100644 requirements_test.txt diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index ecf91a4..ab4c0af 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -28,16 +28,12 @@ jobs: steps: - uses: actions/checkout@v5 - - name: Set up Python - uses: actions/setup-python@v6 - with: - python-version: '3.11' - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install -r requirements_dev.txt + pipx install hatch + hatch env create - name: Build - run: mkdocs build + run: hatch run docs-build - name: Upload artifact uses: actions/upload-pages-artifact@v4 with: diff --git a/pyproject.toml b/pyproject.toml index 19c4548..993faf7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,10 @@ [build-system] -requires = [ - "setuptools>=46.4.0", - "wheel" -] -build-backend = "setuptools.build_meta" +requires = ["hatchling", "hatch-regex-commit"] +build-backend = "hatchling.build" [project] name = "bring-api" -dynamic = ["version", "readme"] +dynamic = ["version"] description = "Unofficial package to access Bring! shopping lists API." authors = [ { name = "Cyrill Raccaud", email = "cyrill.raccaud+pypi@gmail.com" }, @@ -25,17 +22,50 @@ classifiers = [ "Operating System :: OS Independent" ] license = "MIT" +readme = "README.md" + +[tool.hatch.version] +source = "regex_commit" +commit_extra_args = ["-e"] +path = "bring_api/__init__.py" + +[tool.hatch.build.targets.sdist] +include = [ + "/bring_api", +] + +[tool.hatch.envs.default] +dependencies = [ + "aiohttp==3.13.1", + "pre-commit>=3.6.1", + "python-dotenv>=1.0.1", + "ruff~=0.14", + "mkdocs-material==9.6.21", + "mkdocstrings[python]==0.30.1", + "mashumaro>=3.13.1", + "orjson>=3.10.12", +] -[tool.setuptools] -packages = ["bring_api", "bring_api.locales"] +[tool.hatch.envs.hatch-static-analysis] +dependencies = [ + "ruff==0.14.1", + "mypy==1.18.2", + "pydantic==2.12.3", +] +config-path = "none" -[tool.setuptools.package-data] -bring_api = ["py.typed"] -"bring_api.locales" = ["*.json"] +[tool.hatch.envs.hatch-test] +extra-dependencies = [ + "python-dotenv==1.1.1", + "aioresponses==0.7.8", + "pytest-asyncio==1.2.0", + "pytest-cov==7.0.0", + "syrupy==5.0.0", +] -[tool.setuptools.dynamic] -version = {attr = "bring_api.__version__"} -readme = {file = ["README.md"], content-type = "text/markdown"} +[tool.hatch.envs.default.scripts] +docs-serve = "mkdocs serve" +docs-build = "mkdocs build" [project.urls] Documentation = "https://miaucl.github.io/bring-api/" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 5cb31a7..0000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -aiohttp~=3.11 -mashumaro>=3.13.1 -orjson>=3.10.12 \ No newline at end of file diff --git a/requirements_dev.txt b/requirements_dev.txt deleted file mode 100644 index 0778eb4..0000000 --- a/requirements_dev.txt +++ /dev/null @@ -1,10 +0,0 @@ -aiohttp~=3.11 -mypy>=1.8.0 -pydantic>=2.9.2 -pre-commit>=3.6.1 -python-dotenv>=1.0.1 -ruff~=0.14 -mkdocs-material==9.6.21 -mkdocstrings[python]==0.30.1 -mashumaro>=3.13.1 -orjson>=3.10.12 \ No newline at end of file diff --git a/requirements_test.txt b/requirements_test.txt deleted file mode 100644 index 339b63e..0000000 --- a/requirements_test.txt +++ /dev/null @@ -1,6 +0,0 @@ -aioresponses>=0.7.6 -pytest-asyncio>=0.23.6 -pytest-cov>=5.0.0 -pytest>=8.1.1 -python-dotenv>=1.0.1 -syrupy==5.0.0 From 4c4bdef30abee32acc6fed380e3d9c6634dc622b Mon Sep 17 00:00:00 2001 From: tr4nt0r <4445816+tr4nt0r@users.noreply.github.com> Date: Mon, 20 Oct 2025 13:56:26 +0200 Subject: [PATCH 2/4] unit-tests --- .github/workflows/unit-tests.yaml | 12 ++++-------- pyproject.toml | 3 +++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index f55cc1b..8f4e801 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -9,21 +9,17 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v5 - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python uses: actions/setup-python@v6 with: - python-version: ${{ matrix.python-version }} + python-version: "3.14" - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install -r requirements_test.txt + run: pipx install hatch --python python3.14 - name: Test with pytest - run: pytest -v --cov-config=pyproject.toml --cov=bring_api --cov-report=xml + run: hatch test --all - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 with: diff --git a/pyproject.toml b/pyproject.toml index 993faf7..ae0ec2c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,6 +62,8 @@ extra-dependencies = [ "pytest-cov==7.0.0", "syrupy==5.0.0", ] +extra-args = ["--cov-report=xml", "-vv"] +type = "virtual" [tool.hatch.envs.default.scripts] docs-serve = "mkdocs serve" @@ -218,6 +220,7 @@ log_cli = true log_cli_level = "DEBUG" log_cli_format = "%(asctime)s%(msecs)03d [%(levelname)8s] %(name)s:%(lineno)s %(message)s" log_cli_date_format = "%Y%m%dT%H%M%S." +addopts = "--cov=bring_api/ --cov-report=term-missing" [tool.coverage.run] branch = true From 257088e7d527dea34bd5b5b9b0c8cbe28241a040 Mon Sep 17 00:00:00 2001 From: tr4nt0r <4445816+tr4nt0r@users.noreply.github.com> Date: Mon, 20 Oct 2025 14:13:56 +0200 Subject: [PATCH 3/4] python test matrix --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index ae0ec2c..c0cb33e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,6 +64,8 @@ extra-dependencies = [ ] extra-args = ["--cov-report=xml", "-vv"] type = "virtual" +[[tool.hatch.envs.hatch-test.matrix]] +python = ["3.14", "3.13", "3.12", "3.11"] [tool.hatch.envs.default.scripts] docs-serve = "mkdocs serve" From 99525b0633d7606dd7137968a1fa4731ee02bdb6 Mon Sep 17 00:00:00 2001 From: tr4nt0r <4445816+tr4nt0r@users.noreply.github.com> Date: Mon, 20 Oct 2025 14:27:52 +0200 Subject: [PATCH 4/4] user hatch github action --- .github/workflows/documentation.yml | 6 ++---- .github/workflows/unit-tests.yaml | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index ab4c0af..1cca51d 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -28,10 +28,8 @@ jobs: steps: - uses: actions/checkout@v5 - - name: Install dependencies - run: | - pipx install hatch - hatch env create + - name: Install Hatch + uses: pypa/hatch@install - name: Build run: hatch run docs-build - name: Upload artifact diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index 8f4e801..ba4e5da 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -16,8 +16,8 @@ jobs: uses: actions/setup-python@v6 with: python-version: "3.14" - - name: Install dependencies - run: pipx install hatch --python python3.14 + - name: Install Hatch + uses: pypa/hatch@install - name: Test with pytest run: hatch test --all - name: Upload coverage to Codecov