Closed asfaltboy closed 1 year ago
I admit the error is inscrutable. But it's legitimate and Appeal is working correctly.
The problem is the signature of pathlib.Path
:
def __new__(cls, *args, **kwargs):
...
Since the constructor for a pathlib.Path
object will take infinitely many positional arguments, there's no way for any subsequent argument to your command function to accept a positional argument. So Appeal throws an exception.
You could work around it by writing your own function, something like this:
def mypath(path): return pathlib.Path(path)
@appeal.command()
def paths_exist(path1: mypath, path2: mypath):
...
I'll leave the issue open for now, so that I can reflect on how to improve the error message.
What do you think of
This command-line can never be satisfied. Required parameter "paths_exist.path2" can never get an argument, because it comes after "paths_exist.path1", which is type "Path", and that has a "*args" parameter, which means it consumes all remaining command-line arguments
It's a little long, but it sure explains everything.
Fixing this in 0.5.9. The error message I went with is (manually word-wrapped):
ValueError: This command-line can never be satisfied. "fgrep(), argument dst" is a required parameter,
but it can never get an argument, because it comes after VAR_POSITIONAL parameter
"fgrep(), argument src, converter Path(), argument *args" which already consumed
all remaining command-line arguments.
Thank's for writing appeal it's a cool package, and the README is a pleasure to read 🥇
I've come across an issue with using the
pathlib.Path
type, since I wanted to specify path arguments with the rich pathlib API, and I encountered this awkward issue.Example:
Adding an annotation in the first argument raises an error:
Removing the first annotation, and only keeping the annotation in the 2nd argument (and possibly any next params) doesn't raise an error but changes the argument to appear as
[args]...
in the usage line (even though it's a single argument, and not a*arg
.Using appearl 0.5 from pypi on python 3.10