You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is one of my first Issues, so it probably isn't perfect. Sorry if I missed other (related) Issues.
The problem:
The issues is that using the "*" star syntax to define keyword-only arguments in functions, makes the help message of the arguments after the the star (keyword-only arguments) not show up:
@call_parsedeffun(
a:int=3, # The a parameterb:str='string', # comment parameter b*, # Keywords only from now onc:float=0.42, # c param with comment <-- not shown in helpd='var', # The d param comment <-- not shown in helpe=42# Comment 4 e <-- not shown in help
):
"->Documentation<-"returnTrueprint(anno_parser(fun).format_help())
The output:
usage: ipykernel_launcher.py [-h] [--a A] [--b B] [--c C] [--d D] [--e E]
->Documentation<-
options:
-h, --help show this help message and exit
--a A The a parameter (default: 3)
--b B String parameter b (default: string)
--c C (default: 0.42)
--d D (default: var)
--e E (default: 42)
The behavior is also present if I save to a file and run it from the commandline.
The help message for arg c,d & e are missing. If I comment out the "*, " line it works again.
The cause/potential solution:
I think I have tracked down why this happens:
#from fastcore.docments import _param_locsdef_param_locs(s, returns=True):
"`dict` of parameter line numbers to names"body=_parses(s).bodyiflen(body)==1: #or not isinstance(body[0], FunctionDef): return Nonedefn=body[0]
ifisinstance(defn, FunctionDef):
#res = {arg.lineno:arg.arg for arg in defn.args.args} # Original line# Suggested change that makes it work: <---------------------------res= {arg.lineno:arg.argforargin (defn.args.args+defn.args.kwonlyargs)}
ifreturnsanddefn.returns: res[defn.returns.lineno] ='return'returnreselifisdataclass(s):
res= {arg.lineno:arg.target.idforargindefn.bodyifisinstance(arg, AnnAssign)}
returnresreturnNone
Since _param_locs does not return keyword-only arguments (defn.args.kwonlyargs) it does not get matched with its comments and hence does not lead to a help message.
Its probably a bit preliminary, but perhaps I can turn this into a PR after some testing?
The text was updated successfully, but these errors were encountered:
mennowitteveen
changed the title
[@call_parse] Keyword only arguments help-msg not showing in help@call_parse: Keyword only arguments help-msg not showing in help
Jul 27, 2023
mennowitteveen
changed the title
@call_parse: Keyword only arguments help-msg not showing in help@call_parse: Keyword only arguments help-msg not showing in help
Jul 27, 2023
mennowitteveen
changed the title
@call_parse: Keyword only arguments help-msg not showing in help@call_parse: Keyword only arguments help-msg not showing in help
Jul 27, 2023
This is one of my first Issues, so it probably isn't perfect. Sorry if I missed other (related) Issues.
The problem:
The issues is that using the "*" star syntax to define keyword-only arguments in functions, makes the help message of the arguments after the the star (keyword-only arguments) not show up:
The output:
The behavior is also present if I save to a file and run it from the commandline.
The help message for arg c,d & e are missing. If I comment out the "*, " line it works again.
The cause/potential solution:
I think I have tracked down why this happens:
Since _param_locs does not return keyword-only arguments (defn.args.kwonlyargs) it does not get matched with its comments and hence does not lead to a help message.
Its probably a bit preliminary, but perhaps I can turn this into a PR after some testing?
The text was updated successfully, but these errors were encountered: