-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Labels
enhancementNew feature or requestNew feature or requestexternal-requestYou asked, we didYou asked, we did
Description
Requirements:
- When defining arguments with using
pathlib.Path, such asp.add_argument("-s", "--src", type=Path)on anArgumentParserinstance, the autocomplete mechanism should understand the type and emit an autocomplete that is compatible with both a file or directory.
Context/Comments
- Path is commonly used and communicates the fundamental intent that the argument is PathLike.
- Currently, when defining File/Dir, the user needs to add
.complete(e.g.,p.add_argument("-s", "--src", type=Path).complete = shtab.FILE). This is easy to forget and it's not a particulary obvious interface toAction. Also, your text editing won't be able to help or assist you. For example, a simple mistyping of.completion = shtab.FILEcan create confusion. - Adding
.completedoesn't play well with static analysis tools such asmypyin strict mode. Using.complete = ...will yield an error (example.py:29: error: "Action" has no attribute "complete" [attr-defined] - Using
.complete = shtab.FILEmodel requires an explicit dependency onshtab. It's useful to make shtab an optional dependency with a try/catch ImportError and useshtab.add_argument_to(p)when defining aget_parser()function. - If you don't explicitly add
.completestyle for a Path, then you loose any "default" autocomplete mechanics of file/dir behavior in the shell.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestexternal-requestYou asked, we didYou asked, we did