Skip to content

Commit 37f653f

Browse files
authored
Merge pull request #10 from python-project-templates/tkp/hf
Ensure all public functions are exported
2 parents bf86e83 + 878b6c6 commit 37f653f

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

hatch_build/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
__version__ = "0.3.1"
22

3-
from .cli import parse_extra_args
3+
from .cli import *

hatch_build/cli.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
__all__ = (
1010
"hatchling",
1111
"parse_extra_args",
12+
"parse_extra_args_model",
1213
)
1314
_extras = None
1415

@@ -20,7 +21,7 @@ def parse_extra_args(subparser: Optional[ArgumentParser] = None) -> List[str]:
2021
return vars(kwargs), extras
2122

2223

23-
def recurse_add_fields(parser: ArgumentParser, model: "BaseModel", prefix: str = ""):
24+
def _recurse_add_fields(parser: ArgumentParser, model: "BaseModel", prefix: str = ""):
2425
from pydantic import BaseModel
2526

2627
for field_name, field in model.__class__.model_fields.items():
@@ -30,7 +31,7 @@ def recurse_add_fields(parser: ArgumentParser, model: "BaseModel", prefix: str =
3031
parser.add_argument(arg_name, action="store_true", default=field.default)
3132
elif isinstance(field_type, Type) and issubclass(field_type, BaseModel):
3233
# Nested model, add its fields with a prefix
33-
recurse_add_fields(parser, getattr(model, field_name), prefix=f"{field_name}.")
34+
_recurse_add_fields(parser, getattr(model, field_name), prefix=f"{field_name}.")
3435
elif get_origin(field_type) in (list, List):
3536
# TODO: if list arg is complex type, raise as not implemented for now
3637
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"):
6162
# Recursively parse fields from a pydantic model and its sub-models
6263
# and create an argument parser to parse extra args
6364
parser = ArgumentParser(prog="hatch-build-extras-model", allow_abbrev=False)
64-
parser = recurse_add_fields(parser, model)
65+
parser = _recurse_add_fields(parser, model)
6566

6667
# Parse the extra args and update the model
6768
args, kwargs = parse_extra_args(parser)

0 commit comments

Comments
 (0)