update nu_plugin_python due to signature changes (#8107)

# Description

As title..

# User-Facing Changes

None

# Tests + Formatting

Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
This commit is contained in:
WindSoilder 2023-02-18 21:27:24 +08:00 committed by GitHub
parent 66398fbf77
commit 789b2e603a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

130
crates/nu_plugin_python/nu_plugin_python_example.py Normal file → Executable file
View file

@ -1,3 +1,4 @@
#!/usr/bin/env python
# Example of using a Python script as a Nushell plugin
#
# The example uses JSON encoding but it should be a similar process using
@ -38,73 +39,76 @@ def signatures():
return {
"Signature": [
{
"name": "nu-python",
"usage": "Signature test for Python",
"extra_usage": "",
"input_type": "Any",
"output_type": "Any",
"required_positional": [
{
"name": "a",
"desc": "required integer value",
"shape": "Int",
"var_id": None,
},
{
"name": "b",
"desc": "required string value",
"sig": {
"name": "nu-python",
"usage": "Signature test for Python",
"extra_usage": "",
"input_type": "Any",
"output_type": "Any",
"required_positional": [
{
"name": "a",
"desc": "required integer value",
"shape": "Int",
"var_id": None,
},
{
"name": "b",
"desc": "required string value",
"shape": "String",
"var_id": None,
},
],
"optional_positional": [
{
"name": "opt",
"desc": "Optional number",
"shape": "Int",
"var_id": None,
}
],
"rest_positional": {
"name": "rest",
"desc": "rest value string",
"shape": "String",
"var_id": None,
},
],
"optional_positional": [
{
"name": "opt",
"desc": "Optional number",
"shape": "Int",
"var_id": None,
}
],
"rest_positional": {
"name": "rest",
"desc": "rest value string",
"shape": "String",
"var_id": None,
"vectorizes_over_list": False,
"named": [
{
"long": "help",
"short": "h",
"arg": None,
"required": False,
"desc": "Display the help message for this command",
"var_id": None,
},
{
"long": "flag",
"short": "f",
"arg": None,
"required": False,
"desc": "a flag for the signature",
"var_id": None,
},
{
"long": "named",
"short": "n",
"arg": "String",
"required": False,
"desc": "named string",
"var_id": None,
},
],
"input_output_types": [["Any", "Any"]],
"allow_variants_without_examples": True,
"search_terms": ["Python", "Example"],
"is_filter": False,
"creates_scope": False,
"allows_unknown_args": False,
"category": "Experimental",
},
"vectorizes_over_list": False,
"named": [
{
"long": "help",
"short": "h",
"arg": None,
"required": False,
"desc": "Display the help message for this command",
"var_id": None
},
{
"long": "flag",
"short": "f",
"arg": None,
"required": False,
"desc": "a flag for the signature",
"var_id": None,
},
{
"long": "named",
"short": "n",
"arg": "String",
"required": False,
"desc": "named string",
"var_id": None,
},
],
"input_output_types": [["Any", "Any"]],
"allow_variants_without_examples": True,
"search_terms": ["Python", "Example"],
"is_filter": False,
"creates_scope": False,
"allows_unknown_args": False,
"category": "Experimental",
"examples": [],
}
]
}