Skip to main content

Argument classes for callable objects in Python.

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

Contributors Forks Stargazers Issues MIT License LinkedIn

Python ArgumentSignature

Argument classes for callable objects in Python.

Changelog · Report Bug · Request Feature

About The Project

Provides easy-to-use argument features for Python 3.x.

Built With

  • python-shield

Getting Started

To get a local copy up and running follow these simple example steps.

Prerequisites

Does not require any prerequisites

Installation

  1. Clone the repo
git clone https://github.com/TahsinCr/python-argumentsignature.git
  1. 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

argumentsignature-1.0.3.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

argumentsignature-1.0.3-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file argumentsignature-1.0.3.tar.gz.

File metadata

  • Download URL: argumentsignature-1.0.3.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for argumentsignature-1.0.3.tar.gz
Algorithm Hash digest
SHA256 144992a146b396880b0f445f4cf6f9c5782b687675d194e23a7c2f95ac76fbf1
MD5 ba3c333b0b2801770d2199088ee817d8
BLAKE2b-256 7653b31c469393c00cfa2233026b70343d92e14f877d8ef3dbe68e5e9d98bb9d

See more details on using hashes here.

File details

Details for the file argumentsignature-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for argumentsignature-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7502e8a57bdb6e42ccb414f57d6e515e5c098e76c5336e211d1a547a06a52e55
MD5 867082c9ce7687459258352fe89990c3
BLAKE2b-256 6f4d55e3ea2ec80880a4acfacba21044d3d7a04a1094b77ffc9be4556961c3bb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page