Skip to content

Commit

Permalink
Fix validation to always check the configured type for an arg (#80)
Browse files Browse the repository at this point in the history
Also update the readme to always refer to the boolean type correctly.
  • Loading branch information
nat-n committed Jul 16, 2022
1 parent 09cddf3 commit 90107d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -653,9 +653,10 @@ Named arguments support the following configuration options:
- **type** : str
The type that the provided value will be cast to. The set of acceptable options is
{"string", "float", "integer", "boolean"}. If not provided then the default behaviour
is to keep values as strings. Setting the type to "bool" makes the resulting argument
a flag that if provided will set the value to the boolean opposite of the default
value – i.e. *true* if no default value is given, or false if :toml:`default = true`.
is to keep values as strings. Setting the type to "boolean" makes the resulting
argument a flag that if provided will set the value to the boolean opposite of the
default value – i.e. *true* if no default value is given, or false if
:toml:`default = true`.


Arguments for cmd and shell tasks
Expand Down
7 changes: 4 additions & 3 deletions poethepoet/task/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,14 @@ def validate_def(cls, task_name: str, args_def: ArgsDef) -> Optional[str]:
f"Unexpected 'name' option for arg {arg_name!r} of task "
f"{task_name!r}"
)
error = cls._validate_type(params, arg_name, task_name)
if error:
return error
arg_params.append((params, arg_name, task_name))

positional_multiple = None
for params, arg_name, task_name in arg_params:
error = cls._validate_type(params, arg_name, task_name)
if error:
return error

error = cls._validate_params(params, arg_name, task_name)
if error:
return error
Expand Down

0 comments on commit 90107d1

Please sign in to comment.