From 878b6c64c340b9d44600c6793adbf47072ee84b9 Mon Sep 17 00:00:00 2001 From: Tim Paine <3105306+timkpaine@users.noreply.github.com> Date: Thu, 6 Nov 2025 15:52:01 -0500 Subject: [PATCH] Ensure all public functions are exported --- hatch_build/__init__.py | 2 +- hatch_build/cli.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/hatch_build/__init__.py b/hatch_build/__init__.py index 02cd36e..3df35cf 100644 --- a/hatch_build/__init__.py +++ b/hatch_build/__init__.py @@ -1,3 +1,3 @@ __version__ = "0.3.1" -from .cli import parse_extra_args +from .cli import * diff --git a/hatch_build/cli.py b/hatch_build/cli.py index ea46986..b3b42d6 100644 --- a/hatch_build/cli.py +++ b/hatch_build/cli.py @@ -9,6 +9,7 @@ __all__ = ( "hatchling", "parse_extra_args", + "parse_extra_args_model", ) _extras = None @@ -20,7 +21,7 @@ def parse_extra_args(subparser: Optional[ArgumentParser] = None) -> List[str]: return vars(kwargs), extras -def recurse_add_fields(parser: ArgumentParser, model: "BaseModel", prefix: str = ""): +def _recurse_add_fields(parser: ArgumentParser, model: "BaseModel", prefix: str = ""): from pydantic import BaseModel for field_name, field in model.__class__.model_fields.items(): @@ -30,7 +31,7 @@ def recurse_add_fields(parser: ArgumentParser, model: "BaseModel", prefix: str = parser.add_argument(arg_name, action="store_true", default=field.default) elif isinstance(field_type, Type) and issubclass(field_type, BaseModel): # Nested model, add its fields with a prefix - recurse_add_fields(parser, getattr(model, field_name), prefix=f"{field_name}.") + _recurse_add_fields(parser, getattr(model, field_name), prefix=f"{field_name}.") elif get_origin(field_type) in (list, List): # TODO: if list arg is complex type, raise as not implemented for now if get_args(field_type) and get_args(field_type)[0] not in (str, int, float, bool): @@ -61,7 +62,7 @@ def parse_extra_args_model(model: "BaseModel"): # Recursively parse fields from a pydantic model and its sub-models # and create an argument parser to parse extra args parser = ArgumentParser(prog="hatch-build-extras-model", allow_abbrev=False) - parser = recurse_add_fields(parser, model) + parser = _recurse_add_fields(parser, model) # Parse the extra args and update the model args, kwargs = parse_extra_args(parser)