Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
nkvuong committed May 23, 2024
1 parent cc89c55 commit 73c601f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/databricks/labs/blueprint/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ def prompts_argument_name(self) -> str | None:
return param.name
return None

def get_argument_type(self, argument_name: str) -> type:
def get_argument_type(self, argument_name: str) -> str | None:
sig = inspect.signature(self.fn)
return sig.parameters[argument_name].annotation
if argument_name not in sig.parameters:
return None
return sig.parameters[argument_name].annotation.__name__


class App:
Expand Down Expand Up @@ -85,7 +87,7 @@ def _route(self, raw):
cmd = self._mapping[command]
# modify kwargs to match the type of the argument
for kwarg in list(kwargs.keys()):
match cmd.get_argument_type(kwarg).__name__:
match cmd.get_argument_type(kwarg):
case "int":
kwargs[kwarg] = int(kwargs[kwarg])
case "bool":
Expand Down

0 comments on commit 73c601f

Please sign in to comment.