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.txt 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.tar.gz (4.3 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-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: argumentsignature-1.0.tar.gz
  • Upload date:
  • Size: 4.3 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.tar.gz
Algorithm Hash digest
SHA256 c862109fbda0443c31046cfac6818c6090b40cb146869306134166dcee6ad29f
MD5 36a30c573b9daa8cf94ec7ba819851fd
BLAKE2b-256 dc46af8cfe686eb596addcf06fa6e49f4c4ac9a427ab445f262ea27299d38a59

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for argumentsignature-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 020850502f1889f4c66a0c600900d034cd26b2048e9a892ff3e082e8e4597bca
MD5 016917073419bce60dcc3adcda3fe015
BLAKE2b-256 3fc778d08ad2344383f4b3f63edc84feb9542b1ece1d729f5368304b4f5e3016

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