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.1.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.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: argumentsignature-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 4692b1e061766bc18cdbfb2b8b6710d98aadfe8b6e96444a2eef33034e9becfd
MD5 b3d5acd312e89d7e1b5b760ff1b72d2c
BLAKE2b-256 90315894b386a66d6ee27e7dcb1318c0e76526a67453a699b6ae7ca3d0e2b028

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for argumentsignature-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6e95f208e051230275740867bad725d21002d806f363b7944cca17dd205f5005
MD5 4a89f61b181fd48846d081f6c428859c
BLAKE2b-256 1bf0e33b42da03efdaa21693051fda12fda9a095d0f55ba441a9dc2e1477ee72

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