From 0200fd4875fbf1de721af6fe2e117c316f936030 Mon Sep 17 00:00:00 2001 From: "python-templates-copier-update[bot]" Date: Sun, 11 Oct 2026 11:27:06 +0000 Subject: [PATCH 1/2] Update from Copier (2026-10-11T11-27-03Z) Signed-off-by: python-templates-copier-update[bot] --- .copier-answers.yaml | 2 +- .github/workflows/build.yaml | 2 +- Makefile | 10 +++++----- pyproject.toml | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.copier-answers.yaml b/.copier-answers.yaml index 5c3cd04..e1aa128 100644 --- a/.copier-answers.yaml +++ b/.copier-answers.yaml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier -_commit: ebb6e1c +_commit: '4372075' _src_path: https://github.com/python-project-templates/base.git add_docs: false add_extension: python diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b1d4aae..2b4bb7c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -15,7 +15,7 @@ on: workflow_dispatch: concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true permissions: diff --git a/Makefile b/Makefile index cc26bf9..35d7f98 100644 --- a/Makefile +++ b/Makefile @@ -25,16 +25,16 @@ lint-py: ## lint python with ruff python -m ruff format --check hatch_build lint-docs: ## lint docs with mdformat and codespell - python -m mdformat --check README.md - python -m codespell_lib README.md + python -m mdformat --check README.md $(wildcard docs/src) + python -m codespell_lib README.md $(wildcard docs/src) fix-py: ## autoformat python code with ruff python -m ruff check --fix hatch_build python -m ruff format hatch_build fix-docs: ## autoformat docs with mdformat and codespell - python -m mdformat README.md - python -m codespell_lib --write README.md + python -m mdformat README.md $(wildcard docs/src) + python -m codespell_lib --write README.md $(wildcard docs/src) lint: lint-py lint-docs ## run all linters lints: lint @@ -52,7 +52,7 @@ check-dist: ## check python sdist and wheel with check-dist check-types: ## check python types with ty ty check --python $$(which python) -checks: check-dist +checks: check-dist check-types # Alias check: checks diff --git a/pyproject.toml b/pyproject.toml index 42bf880..c60cf81 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,6 +46,7 @@ develop = [ "codespell", "hatchling", "mdformat", + "mdformat-frontmatter", "mdformat-tables>=1", "pydantic>=2,<3", "pytest", @@ -83,7 +84,7 @@ replace = 'version = "{new_version}"' [tool.coverage.run] branch = true omit = [ - "hatch_build/tests/integration/", + "hatch_build/tests/integration/*", ] [tool.coverage.report] From 12a5f98a74cef64875c7756012c90a888e44f9bb Mon Sep 17 00:00:00 2001 From: Tim Paine <3105306+timkpaine@users.noreply.github.com> Date: Sun, 11 Oct 2026 10:58:07 -0400 Subject: [PATCH 2/2] Correct CLI parser return types Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com> --- Makefile | 8 ++++---- hatch_build/cli.py | 14 ++++++++------ hatch_build/tests/test_cli_model.py | 3 ++- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 35d7f98..4944de8 100644 --- a/Makefile +++ b/Makefile @@ -25,16 +25,16 @@ lint-py: ## lint python with ruff python -m ruff format --check hatch_build lint-docs: ## lint docs with mdformat and codespell - python -m mdformat --check README.md $(wildcard docs/src) - python -m codespell_lib README.md $(wildcard docs/src) + python -m mdformat --check README.md $(wildcard docs/src) + python -m codespell_lib README.md $(wildcard docs/src) fix-py: ## autoformat python code with ruff python -m ruff check --fix hatch_build python -m ruff format hatch_build fix-docs: ## autoformat docs with mdformat and codespell - python -m mdformat README.md $(wildcard docs/src) - python -m codespell_lib --write README.md $(wildcard docs/src) + python -m mdformat README.md $(wildcard docs/src) + python -m codespell_lib --write README.md $(wildcard docs/src) lint: lint-py lint-docs ## run all linters lints: lint diff --git a/hatch_build/cli.py b/hatch_build/cli.py index d134790..eb5215f 100644 --- a/hatch_build/cli.py +++ b/hatch_build/cli.py @@ -1,6 +1,6 @@ from argparse import ArgumentParser from collections.abc import Callable -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Any, TypeVar, cast from hatchling.cli.build import build_command from p2a import parse_extra_args_model as base_parse_extra_args_model @@ -13,21 +13,22 @@ "parse_extra_args", "parse_extra_args_model", ) -_extras = None +_extras: list[str] | None = None +ModelT = TypeVar("ModelT", bound="BaseModel") -def parse_extra_args(subparser: ArgumentParser | None = None) -> list[str]: +def parse_extra_args(subparser: ArgumentParser | None = None) -> tuple[dict[str, Any], list[str]]: if subparser is None: subparser = ArgumentParser(prog="hatch-build-extras", allow_abbrev=False) kwargs, extras = subparser.parse_known_args(_extras or []) return vars(kwargs), extras -def parse_extra_args_model(model: "BaseModel"): - return base_parse_extra_args_model(model, _extras) +def parse_extra_args_model(model: ModelT) -> tuple[ModelT, list[str]]: + return cast(tuple[ModelT, list[str]], base_parse_extra_args_model(model, _extras or [])) -def _hatchling_internal() -> tuple[Callable | None, dict | None, list[str]]: +def _hatchling_internal() -> tuple[Callable | None, dict | None, list[str] | None]: parser = ArgumentParser(prog="hatch-build", allow_abbrev=False) subparsers = parser.add_subparsers() @@ -64,6 +65,7 @@ def hatchling() -> int: command, kwargs, extras = _hatchling_internal() if command is None: return 1 + assert kwargs is not None # Set so plugins can reference _extras = extras diff --git a/hatch_build/tests/test_cli_model.py b/hatch_build/tests/test_cli_model.py index 49c8c05..70456f3 100644 --- a/hatch_build/tests/test_cli_model.py +++ b/hatch_build/tests/test_cli_model.py @@ -50,7 +50,7 @@ class MyTopLevelModel(BaseModel, validate_assignment=True): dict_enum_key_model_value: dict[MyEnum, SubModel] = {MyEnum.OPTION_A: SubModel()} submodel: SubModel - submodel2: SubModel = SubModel(sub_args=84, sub_arg_with_value="predefined", sub_arg_enum=MyEnum.OPTION_B, sub_arg_literal="z") + submodel2: SubModel = SubModel(sub_arg=84, sub_arg_with_value="predefined", sub_arg_enum=MyEnum.OPTION_B, sub_arg_literal="z") submodel3: RuntimeOptional[SubModel] = None submodel_list_instanced: list[SubModel] = [SubModel()] @@ -171,6 +171,7 @@ def test_get_arg_from_model(self): assert model.submodel2.sub_arg_enum == MyEnum.OPTION_B assert model.submodel2.sub_arg_literal == "z" + assert model.submodel3 is not None assert model.submodel3.sub_arg == 300 assert model.submodel_list_instanced[0].sub_arg == 400 assert model.submodel_list_instanced[0].sub_arg_with_value == "list_value"