This release is a pre-release and may not be stable for production use.
Swarmauri Tool Get Method Signature
swarmauri_tool_getmethodsignature is a Swarmauri tool that parses Python
source code with the standard-library ast module and returns the
signature of a specified function or method, including its name,
parameters, and return type. It is useful for documentation generation,
refactoring assistants, agent-driven code review, and static
introspection workflows.
Why Use Swarmauri Tool Get Method Signature
- Inspect function and method signatures without importing source code.
- Capture parameter names, annotations, and defaults in one call.
- Detect overloaded definitions that share a single function name.
- Distinguish synchronous functions from
async defcoroutines. - Reuse the same tool in agents, notebooks, scripts, and backend workflows.
FAQ
What does the tool return?
A dictionary withname,parameters,return_type,signature, andis_async. When multiple definitions share the requested name, it returns{"overloads": [...]}instead.
Does the tool execute the source code?
No. It usesast.parsefor purely static analysis and never imports or executes the supplied source.
What happens when the function is missing?
The tool returns{"error": "..."}describing the failure, including cases where the source cannot be parsed.
Are parameter defaults and annotations captured?
Yes. Each parameter entry includesname,annotation(when present), anddefault(when present), rendered back to source text viaast.unparse.
Features
- Swarmauri
ToolBaseimplementation registered asGetMethodSignatureTool. - Static
ast-based parsing with no dynamic code execution. - Support for positional-only, keyword-only,
*args, and**kwargsparameters. - Detection of overloaded functions sharing a single name.
- Renders a human-readable
signaturestring for each definition. - Supports Python 3.10, 3.11, 3.12, 3.13, and 3.14.
Installation
uv add swarmauri_tool_getmethodsignature
pip install swarmauri_tool_getmethodsignature
Usage
from swarmauri_tool_getmethodsignature import GetMethodSignatureTool
tool = GetMethodSignatureTool()
source = "def add(a: int, b: int = 0) -> int:\n return a + b\n"
result = tool(source=source, method_name="add")
print(result["signature"])
# def add(a: int, b: int = 0) -> int
Examples
Inspect an async method inside a class
from swarmauri_tool_getmethodsignature import GetMethodSignatureTool
tool = GetMethodSignatureTool()
source = (
"class Service:\n"
" async def fetch(self, url: str) -> bytes:\n"
" ...\n"
)
result = tool(source=source, method_name="fetch")
print(result["is_async"]) # True
print(result["return_type"]) # bytes
Detect overloaded definitions
from swarmauri_tool_getmethodsignature import GetMethodSignatureTool
tool = GetMethodSignatureTool()
source = (
"def process(x: int) -> int:\n"
" return x\n"
"def process(x: str) -> str:\n"
" return x\n"
)
result = tool(source=source, method_name="process")
print(len(result["overloads"])) # 2
Register the tool inside a Swarmauri tool registry
from swarmauri_standard.tools.ToolCollection import ToolCollection
from swarmauri_tool_getmethodsignature import GetMethodSignatureTool
tools = ToolCollection(tools=[GetMethodSignatureTool()])
print(tools)
Related Packages
- swarmauri_tool_searchword
- swarmauri_tool_textlength
- swarmauri_tool_sentencecomplexity
- swarmauri_tool_lexicaldensity
- swarmauri_tool_smogindex
Swarmauri Foundations
More Documentation
Best Practices
- Pass complete, syntactically valid Python source for best results.
- Treat the
signaturestring as a rendering hint rather than canonical source; round-trip formatting depends on the Python version. - Use the
overloadslist when auditing code that relies on name reuse. - Pair this tool with documentation generators to enrich API references.
- Avoid relying on dynamic imports; this tool performs static analysis only.
Note: This tool performs static analysis on Python source code strings via the
astmodule. For runtime inspection of already-imported callables, seeMethodSignatureExtractorinswarmauri_standard.utils.method_signature_extractor_decorator.
License
This project is licensed under the Apache-2.0 License.
Metadata
Release files for swarmauri_tool_getmethodsignature 0.11.0.dev3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| swarmauri_tool_getmethodsignature-0.11.0.dev3.tar.gz | 9.4 kB | Without provenance | Details for swarmauri_tool_getmethodsignature-0.11.0.dev3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| swarmauri_tool_getmethodsignature-0.11.0.dev3-py3-none-any.whl | Python 3 | none | any | Details for swarmauri_tool_getmethodsignature-0.11.0.dev3-py3-none-any.whl |
Total release size: 19.9 kB
Release files / swarmauri_tool_getmethodsignature-0.11.0.dev3.tar.gz
| Download URL | swarmauri_tool_getmethodsignature-0.11.0.dev3.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e0c3cc7d2d4c88aca67a23d029476f2520421361240807e8a6168512bdcacc3a
|
|
BLAKE2b-256 checksum How to use checksums |
84e5a27a680a8c80b5cc3df1fe3d748f10f4db66a9d44cbd099a25412af16475
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / swarmauri_tool_getmethodsignature-0.11.0.dev3-py3-none-any.whl
| Download URL | swarmauri_tool_getmethodsignature-0.11.0.dev3-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e58214ebaf0535baca372a963b73e786b79e40447c1b7b391a4b0199e67fc4a6
|
|
BLAKE2b-256 checksum How to use checksums |
b441cceaeabe3c34402e34d7d7907fb295839e9130570aae77f8b9bc635fa277
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for swarmauri_tool_getmethodsignature 0.11.0.dev3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.