SigScaffold
A lightweight Python tool to derive structured information from the signatures of functions and classes.
SigScaffold inspects any callable (like a function or a class constructor) and extracts details about its parameters, including their names, types, and default values. This is particularly useful for automatically generating documentation, configuration files, or API contracts.
Features
- Get parameter names and their type annotations.
- Recursively inspect signatures of class-based parameters.
- Identify which parameters are required.
- Generate sensible default values for all parameters.
- No external dependencies.
Installation
pip install sig-scaffold
Usage
Here is a quick example of how to use SigScaffold:
from sig_scaffold import SigScaffold
# -- Define a class to inspect ---
class DatabaseConfig:
def __init__(self, host: str, port: int = 5432):
self.host = host
self.port = port
def connect(db_config: DatabaseConfig, timeout: int = 30):
"""Connects to a database with the given configuration."""
pass
# -- Use SigScaffold ---
# 1. Inspect the 'connect' function
scaffold = SigScaffold(connect)
# 2. Get parameter types (with recursion)
# This will look inside the DatabaseConfig class as well.
param_types = scaffold.get_param_types(recursive=True)
print("Parameter Types:")
# Expected output:
# {
# 'db_config': {'host': <class 'str'>, 'port': <class 'int'>},
# 'timeout': <class 'int'>
# }
import json
print(json.dumps(
{k: str(v) for k, v in param_types.items()},
indent=2
))
# 3. Get only the required parameters
required = scaffold.get_required_params()
print(f"\nRequired Parameters: {required}")
# Expected output: ['db_config']
# 4. Generate default values for all parameters
defaults = scaffold.generate_defaults()
print(f"\nGenerated Defaults: {defaults}")
# Expected output: {'db_config': '', 'timeout': 30}
Metadata
Release files for SigScaffold 0.1.0
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 | |
|---|---|---|---|---|
| sigscaffold-0.1.0.tar.gz | 5.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sigscaffold-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.7 kB
Release files / sigscaffold-0.1.0.tar.gz
| Download URL | sigscaffold-0.1.0.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e6b082f03c060cdabc5095a33907acaf8ca0838f6503222cb302e6997135839d
|
|
BLAKE2b-256 checksum How to use checksums |
6e9124aeedc832fa3c2c34cfb845c0cd407af356d222652d411f60502ddcb880
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.10
|
Release files / sigscaffold-0.1.0-py3-none-any.whl
| Download URL | sigscaffold-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d84ff4b21dde2298b7c802534595d7dc649c8ca337527f028f2b338bd1c1528d
|
|
BLAKE2b-256 checksum How to use checksums |
1d2efe8043483b2124eaf77309a176c4c07d1153fa9b117e501cd83b3e428a8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.10
|
Security for SigScaffold 0.1.0
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.