Skip to content

Commit

Permalink
Fix handling of bool args (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Oct 14, 2022
1 parent 98345b2 commit 8257c85
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions hatch_jupyter_builder/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def initialize(self, version, build_data):
for key in list(kwargs):
if key not in available_fields:
del kwargs[key]
config = JupyterBuildConfig(**kwargs) # type: ignore[arg-type]
config = JupyterBuildConfig(**kwargs)

should_install_hook = config.install_pre_commit_hook
should_install_hook = config.install_pre_commit_hook.lower() == "true"

if version == "editable" and should_install_hook:
install_pre_commit_hook()
Expand Down
4 changes: 3 additions & 1 deletion hatch_jupyter_builder/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,12 @@ def normalize_cmd(cmd: Union[str, list]) -> List[str]:
return cmd


def normalize_kwargs(kwargs: Mapping[str, str]) -> Dict[str, str]:
def normalize_kwargs(kwargs: Mapping[str, str]) -> Dict[str, Any]:
"""Normalize the key names in a kwargs input dictionary"""
result = {}
for key, value in kwargs.items():
if isinstance(value, bool):
value = str(value)
result[key.replace("-", "_")] = value
return result

Expand Down
6 changes: 6 additions & 0 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ def foo(target_name, version, foo_bar=None, fizz_buzz=None):
warnings.simplefilter("ignore")
assert hook.initialize("editable", {})

config["optional-editable-build"] = True
hook = JupyterBuildHook(tmp_path, config, {}, {}, tmp_path, "wheel")
with warnings.catch_warnings():
warnings.simplefilter("ignore")
assert hook.initialize("editable", {})

del sys.modules["test"]


Expand Down

0 comments on commit 8257c85

Please sign in to comment.