From ad589bdbe1d48d07e1fd85fb075e024c460d7b07 Mon Sep 17 00:00:00 2001 From: jerempy Date: Mon, 10 Oct 2022 10:49:45 -0400 Subject: [PATCH 1/2] Update documentation --- docs/advanced.rst | 15 ++++++++++++++- pipenv/cmdparse.py | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/advanced.rst b/docs/advanced.rst index eb75d50ab3..8c585f3359 100644 --- a/docs/advanced.rst +++ b/docs/advanced.rst @@ -581,7 +581,20 @@ For example: $ pipenv run echospam "indeed" I am really a very silly example indeed -You can then display the names and commands of your shortcuts by running ``pipenv scripts`` in your terminal. +You can also specify pacakge functions as callables such as: ``:``. These can also take arguments. +For exaple: + +.. code-block:: toml + + [scripts] + my_func_with_args = {call = "package.module:func('arg1', 'arg2')"} + my_func_no_args = {call = "package.module:func()"} + +:: + $ pipenv run my_func_with_args + $ pipenv run my_func_no_args + +You can display the names and commands of your shortcuts by running ``pipenv scripts`` in your terminal. :: diff --git a/pipenv/cmdparse.py b/pipenv/cmdparse.py index 0056a09cd1..cd1c1bcd0d 100644 --- a/pipenv/cmdparse.py +++ b/pipenv/cmdparse.py @@ -32,7 +32,7 @@ def _parse_toml_inline_table(value: tomlkit.items.InlineTable) -> str: if cmd_key == "call": module, _, func = str(value["call"]).partition(":") if not module or not func: - raise ScriptParseError("Callable must be like: :") + raise ScriptParseError("Callable must be like: name = {call = \"package.module:func('arg')\"}") if re.search(r"\(.*?\)", func) is None: func += "()" return f'python -c "import {module} as _m; _m.{func}"' From e36c62a7d71b95afd7775ade31de0d7ecdb87d08 Mon Sep 17 00:00:00 2001 From: jerempy Date: Mon, 10 Oct 2022 10:56:12 -0400 Subject: [PATCH 2/2] news seg and lint --- docs/advanced.rst | 8 ++++---- news/5396.doc.rst | 1 + pipenv/cmdparse.py | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 news/5396.doc.rst diff --git a/docs/advanced.rst b/docs/advanced.rst index 8c585f3359..43847cfd09 100644 --- a/docs/advanced.rst +++ b/docs/advanced.rst @@ -581,8 +581,8 @@ For example: $ pipenv run echospam "indeed" I am really a very silly example indeed -You can also specify pacakge functions as callables such as: ``:``. These can also take arguments. -For exaple: +You can also specify pacakge functions as callables such as: ``:``. These can also take arguments. +For exaple: .. code-block:: toml @@ -592,8 +592,8 @@ For exaple: :: $ pipenv run my_func_with_args - $ pipenv run my_func_no_args - + $ pipenv run my_func_no_args + You can display the names and commands of your shortcuts by running ``pipenv scripts`` in your terminal. :: diff --git a/news/5396.doc.rst b/news/5396.doc.rst new file mode 100644 index 0000000000..ba10e37f85 --- /dev/null +++ b/news/5396.doc.rst @@ -0,0 +1 @@ +Update pipenv docs for with example for callabale package functions in Pipfile scripts diff --git a/pipenv/cmdparse.py b/pipenv/cmdparse.py index cd1c1bcd0d..8ba461778a 100644 --- a/pipenv/cmdparse.py +++ b/pipenv/cmdparse.py @@ -32,7 +32,9 @@ def _parse_toml_inline_table(value: tomlkit.items.InlineTable) -> str: if cmd_key == "call": module, _, func = str(value["call"]).partition(":") if not module or not func: - raise ScriptParseError("Callable must be like: name = {call = \"package.module:func('arg')\"}") + raise ScriptParseError( + "Callable must be like: name = {call = \"package.module:func('arg')\"}" + ) if re.search(r"\(.*?\)", func) is None: func += "()" return f'python -c "import {module} as _m; _m.{func}"'