Skip to main content

ConPYguration

Configure your Python function or class with ConPYguration. ConPYguration is a Python library that allows you to easily configure your Python functions or classes with a configuration file or Dictionary.

Installation

pip install conpyguration

Usage

Basic Function

from conpyguration import get_conpyguration

def my_function(a, b=1) -> int:
    return a + b

get_conpyguration(my_function)
# {
#     'description': <class 'conpyguration.types.UNDEFINED'>,
#     'module_name': '__main__',
#     'function_name': 'my_function',
#     'arguments': {
#         'a': {
#             'value_type': <class 'conpyguration.types.UNDEFINED'>,
#             'default': <class 'conpyguration.types.UNDEFINED'>,
#             'description': <class 'conpyguration.types.UNDEFINED'>,
#             'choices': <class 'conpyguration.types.UNDEFINED'>},
#             'b': {
#                 'value_type': <class 'conpyguration.types.UNDEFINED'>,
#                 'default': 1,
#                 'description': <class 'conpyguration.types.UNDEFINED'>,
#                 'choices': <class 'conpyguration.types.UNDEFINED'>
#             }
#         },
#     'return_spec': {
#         'value_type': <class 'int'>,
#         'description': <class 'conpyguration.types.UNDEFINED'>
#     }
# }

Functions with docstrings

def my_function(a: int, b: int=1) -> int:
    """
    This is a function that adds two numbers together.

    Args:
        a (int): The first number.
        b (int, optional): The second number. Defaults to 1.

    Returns:
        int: The sum of the two numbers.
    """
    return a + b

get_conpyguration(my_function)
# {
#     'description': 'This is a function that adds two numbers together.',
#     'module_name': '__main__',
#     'function_name': 'my_function',
#     'arguments': {
#         'a': {
#             'value_type': <class 'int'>,
#             'default': <class 'conpyguration.types.UNDEFINED'>,
#             'description': 'The first number.',
#             'choices': <class 'conpyguration.types.UNDEFINED'>
#         },
#         'b': {
#             'value_type': <class 'int'>,
#             'default': 1,
#             'description': 'The second number. Defaults to 1.',
#             'choices': <class 'conpyguration.types.UNDEFINED'>
#         }
#     },
#     'return_spec': {
#         'value_type': <class 'int'>,
#         'description': 'The sum of the two numbers.'
#     }
# }

Functions with Union types

from typing import Union

def my_function(a: Union[int, float]):
    return

get_conpyguration(my_function)
# {
#     'description': <class 'conpyguration.types.UNDEFINED'>,
#     'module_name': '__main__',
#     'function_name': 'my_function',
#     'arguments': {
#         'a': {
#             'value_type': (<class 'int'>, <class 'float'>),
#             'default': <class 'conpyguration.types.UNDEFINED'>,
#             'description': <class 'conpyguration.types.UNDEFINED'>,
#             'choices': <class 'conpyguration.types.UNDEFINED'>
#         }
#     },
#     'return_spec': <class 'conpyguration.types.UNDEFINED'>
# }

Functions with Literal types (choice)

from typing import Literal

def my_function(a: Literal[1, 2, 3]):
    return

get_conpyguration(my_function)
# {
#     'description': <class 'conpyguration.types.UNDEFINED'>,
#     'module_name': '__main__',
#     'function_name': 'my_function',
#     'arguments': {
#         'a': {
#             'value_type': typing.Literal,
#             'default': <class 'conpyguration.types.UNDEFINED'>,
#             'description': <class 'conpyguration.types.UNDEFINED'>,
#             'choices': (1, 2, 3)
#         }
#     },
#     'return_spec': <class 'conpyguration.types.UNDEFINED'>
# }

Class

from conpyguration import get_class_conpyguration

class MyClass:
    """My Sample Class

    Args:
        a (int): The first number.
        b (int, optional): The second number. Defaults to 1.
    """

    def __init__(self, a: int, b: int=1):
        self.a = a
        self.b = b

    def add(self) -> int:
        """Add the two numbers together.

        Returns:
            int: The sum of the two numbers.
        """
        return self.a + self.b

get_class_conpyguration(MyClass)
# {
#     'description': 'My Sample Class',
#     'module_name': '__main__',
#     'class_name': 'MyClass',
#     'init_arguments': {
#         'a': {
#             'value_type': <class 'int'>,
#             'default': <class 'conpyguration.types.UNDEFINED'>,
#             'description': 'The first number.',
#             'choices': <class 'conpyguration.types.UNDEFINED'>
#         },
#         'b': {
#             'value_type': <class 'int'>,
#             'default': 1,
#             'description': 'The second number. Defaults to 1.',
#             'choices': <class 'conpyguration.types.UNDEFINED'>
#         }
#     },
#     'methods': {
#         'add': {
#             'description': 'Add the two numbers together.',
#             'module_name': '__main__',
#             'function_name': 'MyClass.add',
#             'arguments': {},
#             'return_spec': {
#                 'value_type': <class 'int'>,
#                 'description': 'The sum of the two numbers.'
#             }
#         }
#     }
# }

Metadata

Release files for conpyguration 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for conpyguration 0.1.0
File Size Uploaded
conpyguration-0.1.0.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for conpyguration 0.1.0
File Interpreter ABI Platform
conpyguration-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.7 kB

Release files / conpyguration-0.1.0.tar.gz

Download URL conpyguration-0.1.0.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
dbb0e140206b73a337117f00550f92c4aafc13dc88b939ff84371539aaa12008
BLAKE2b-256 checksum
How to use checksums
5aa1f67d966f232c5afda6c835a58dc31d0859205aa715b5bbeb662d1b2d9acc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release files / conpyguration-0.1.0-py3-none-any.whl

Download URL conpyguration-0.1.0-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
60c66a6e2b2ac568256e74e2a2ceaf4773518a5d6af4b0af1dc16452f8c38be8
BLAKE2b-256 checksum
How to use checksums
5b7e3889f92fd94892c6c20413add93d11814cc98f40cc8f7bba8c69810ccb2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page