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 # Example of using a Python script as a Nushell plugin
# #
# The example uses JSON encoding but it should be a similar process using # The example uses JSON encoding but it should be a similar process using
@ -38,73 +39,76 @@ def signatures():
return { return {
"Signature": [ "Signature": [
{ {
"name": "nu-python", "sig": {
"usage": "Signature test for Python", "name": "nu-python",
"extra_usage": "", "usage": "Signature test for Python",
"input_type": "Any", "extra_usage": "",
"output_type": "Any", "input_type": "Any",
"required_positional": [ "output_type": "Any",
{ "required_positional": [
"name": "a", {
"desc": "required integer value", "name": "a",
"shape": "Int", "desc": "required integer value",
"var_id": None, "shape": "Int",
}, "var_id": None,
{ },
"name": "b", {
"desc": "required string value", "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", "shape": "String",
"var_id": None, "var_id": None,
}, },
], "vectorizes_over_list": False,
"optional_positional": [ "named": [
{ {
"name": "opt", "long": "help",
"desc": "Optional number", "short": "h",
"shape": "Int", "arg": None,
"var_id": None, "required": False,
} "desc": "Display the help message for this command",
], "var_id": None,
"rest_positional": { },
"name": "rest", {
"desc": "rest value string", "long": "flag",
"shape": "String", "short": "f",
"var_id": None, "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, "examples": [],
"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",
} }
] ]
} }