Skip to content

Commit ec76bb2

Browse files
committed
fixes #247
1 parent 401afcc commit ec76bb2

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

fastcore/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.3.12"
1+
__version__ = "1.3.13"

fastcore/script.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
'SCRIPT_INFO', 'call_parse']
55

66
# Cell
7-
import inspect,functools
8-
import argparse
7+
import inspect,functools,argparse,shutil
98
from .imports import *
109
from .utils import *
1110

@@ -61,7 +60,9 @@ def __repr__(self):
6160
# Cell
6261
def anno_parser(func, prog=None, from_name=False):
6362
"Look at params (annotated with `Param`) in func and return an `ArgumentParser`"
64-
p = argparse.ArgumentParser(description=func.__doc__, prog=prog)
63+
cols = shutil.get_terminal_size((120,30))[0]
64+
fmtr = partial(argparse.HelpFormatter, max_help_position=cols//2, width=cols)
65+
p = argparse.ArgumentParser(description=func.__doc__, prog=prog, formatter_class=fmtr)
6566
for k,v in inspect.signature(func).parameters.items():
6667
param = func.__annotations__.get(k, Param())
6768
param.set_default(v.default)

nbs/08_script.ipynb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@
147147
"outputs": [],
148148
"source": [
149149
"#export\n",
150-
"import inspect,functools\n",
151-
"import argparse\n",
150+
"import inspect,functools,argparse,shutil\n",
152151
"from fastcore.imports import *\n",
153152
"from fastcore.utils import *"
154153
]
@@ -329,7 +328,9 @@
329328
"#export\n",
330329
"def anno_parser(func, prog=None, from_name=False):\n",
331330
" \"Look at params (annotated with `Param`) in func and return an `ArgumentParser`\"\n",
332-
" p = argparse.ArgumentParser(description=func.__doc__, prog=prog)\n",
331+
" cols = shutil.get_terminal_size((120,30))[0]\n",
332+
" fmtr = partial(argparse.HelpFormatter, max_help_position=cols//2, width=cols)\n",
333+
" p = argparse.ArgumentParser(description=func.__doc__, prog=prog, formatter_class=fmtr)\n",
333334
" for k,v in inspect.signature(func).parameters.items():\n",
334335
" param = func.__annotations__.get(k, Param())\n",
335336
" param.set_default(v.default)\n",

settings.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ author = Jeremy Howard and Sylvain Gugger
77
author_email = [email protected]
88
copyright = fast.ai
99
branch = master
10-
version = 1.3.12
10+
version = 1.3.13
1111
min_python = 3.6
1212
audience = Developers
1313
language = English

0 commit comments

Comments
 (0)