Skip to content

Commit

Permalink
fix: typer BadParameter
Browse files Browse the repository at this point in the history
  • Loading branch information
maxb2 committed May 1, 2023
1 parent d59962e commit 64868a3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions tests/test_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,21 @@ def test_simple_example(simple_app):

result = RUNNER.invoke(_app, ["--config", conf])

assert result.exit_code == 0, f"Loading failed for {conf}, {callback}"
assert result.exit_code == 0, f"Loading failed for {conf}"
assert (
result.stdout.strip() == "things nothing stuff"
), f"Unexpected output for {conf}"

result = RUNNER.invoke(_app, ["--config", conf, "others"])

assert result.exit_code == 0, f"Loading failed for {conf}, {callback}"
assert result.exit_code == 0, f"Loading failed for {conf}"
assert (
result.stdout.strip() == "things nothing others"
), f"Unexpected output for {conf}"

result = RUNNER.invoke(_app, ["--config", conf, "--opt1", "people"])

assert result.exit_code == 0, f"Loading failed for {conf}, {callback}"
assert result.exit_code == 0, f"Loading failed for {conf}"
assert (
result.stdout.strip() == "people nothing stuff"
), f"Unexpected output for {conf}"
2 changes: 1 addition & 1 deletion typer_config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _callback(ctx: typer.Context, param: typer.CallbackParam, value: Any) -> Any
ctx.default_map = ctx.default_map or {} # Initialize the default map
ctx.default_map.update(conf) # Merge the config Dict into default_map
except Exception as ex:
raise typer.BadParameter(value) from ex
raise typer.BadParameter(value, ctx=ctx, param=param) from ex
return value

return _callback
Expand Down

0 comments on commit 64868a3

Please sign in to comment.