This project has been archived by its maintainers, and is no longer receiving any updates.
Python ArgumentSignature
Argument classes for callable objects in Python.
About The Project
Provides easy-to-use argument features for Python 3.x.
Built With
Getting Started
To get a local copy up and running follow these simple example steps.
Prerequisites
Does not require any prerequisites
Installation
- Clone the repo
git clone https://github.com/TahsinCr/python-argumentsignature.git
- Install PIP packages
pip install argumentsignature
Usage
Can store the arguments and values of callable objects.
from argumentsignature import Argument, ArgumentValue, ARG, ARGS, KWARGS
def item_to_string(key1:str, key2:str, *keys:str, **items:int):
itmes = [f'{k}:{v}' for k, v in items]
return ", ".join([key1, key2, *keys, itmes])
arg_items = item_to_string.__annotations__.items()
code = item_to_string.__code__
arg_defaults = item_to_string.__kwdefaults__ or {}
names = code.co_varnames
arg_keys = names[:code.co_argcount]
kwarg_keys = list(arg_defaults.keys())
is_args = True
arguments:list[Argument] = []
for arg_name, arg_type in arg_items:
if arg_name in arg_keys:
arguments.append(Argument(
name = arg_name,
type = arg_type,
argtype = ARG
))
elif arg_name in kwarg_keys:
arguments.append(Argument(
name = arg_name,
type = arg_type,
default = arg_defaults[arg_name],
argtype = ARG
))
elif arg_name == 'return':
continue
else:
arguments.append(Argument(
name = arg_name,
type = arg_type,
argtype = ARGS if is_args else KWARGS
))
is_args = False
print("\n\n".join([str(x) for x in arguments]))
Output
Argument(name: key1, type: <class 'str'>, default: Ellipsis, argtype: ARG)
Argument(name: key2, type: <class 'str'>, default: Ellipsis, argtype: ARG)
Argument(name: keys, type: <class 'str'>, default: Ellipsis, argtype: ARGS)
Argument(name: items, type: <class 'int'>, default: Ellipsis, argtype: KWARGS)
For more examples, please refer to the Documentation
License
Distributed under the MIT License. See LICENSE for more information.
Contact
Tahsin Çirkin - @TahsinCrs - TahsinCr@outlook.com
Project: TahsinCr/python-argumentsignature
Release files for argumentsignature 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| argumentsignature-1.0.3.tar.gz | 4.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| argumentsignature-1.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.0 kB
Release files / argumentsignature-1.0.3.tar.gz
| Download URL | argumentsignature-1.0.3.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
144992a146b396880b0f445f4cf6f9c5782b687675d194e23a7c2f95ac76fbf1
|
|
BLAKE2b-256 checksum How to use checksums |
7653b31c469393c00cfa2233026b70343d92e14f877d8ef3dbe68e5e9d98bb9d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / argumentsignature-1.0.3-py3-none-any.whl
| Download URL | argumentsignature-1.0.3-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7502e8a57bdb6e42ccb414f57d6e515e5c098e76c5336e211d1a547a06a52e55
|
|
BLAKE2b-256 checksum How to use checksums |
6f4d55e3ea2ec80880a4acfacba21044d3d7a04a1094b77ffc9be4556961c3bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|