Skip to content

Commit 22c0373

Browse files
ziltoskrawcz
authored andcommitted
resolved arg name conflict
1 parent 762128c commit 22c0373

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

hamilton/plugins/jupyter_magic.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def resolve_config_arg(self, config_arg) -> Union[bool, dict]:
212212
return config
213213

214214
@magic_arguments() # needed on top to enable parsing
215-
@argument("module_name", nargs="?", help="Name for the module defined in this cell.")
215+
@argument("name", nargs="?", help="Name for the module defined in this cell.")
216216
@argument(
217217
"-m",
218218
"--module_name",
@@ -311,8 +311,15 @@ def B(A: int) -> bool:
311311
if config is False:
312312
return
313313

314-
# resolve the values of args
315-
module_name = args.module_name
314+
# check if string instance because module_name has default `True`
315+
if isinstance(args.name, str) and isinstance(args.module_name, str):
316+
print(
317+
f"ValueError: Received both positional arg name={args.name} and named arg module_name={args.module_name}. Pass either one."
318+
)
319+
return
320+
321+
# merged the positional arg `name` with named arg `module_name` for backwards compatibility
322+
module_name = args.module_name if isinstance(args.module_name, str) else args.name
316323
base_builder = self.shell.user_ns[args.builder] if args.builder else driver.Builder()
317324
inputs = self.shell.user_ns[args.inputs] if args.inputs else {}
318325
overrides = self.shell.user_ns[args.overrides] if args.overrides else {}

0 commit comments

Comments
 (0)