configure your python class
Project description
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
Coming soon...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
conpyguration-0.1.0a0.tar.gz
(2.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file conpyguration-0.1.0a0.tar.gz.
File metadata
- Download URL: conpyguration-0.1.0a0.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b21549ce1b9fed3420d9c08643dbac2cc374dcc4744ad49364d64883e115ad4e
|
|
| MD5 |
36c64a534a5df7d0ecb4dc50137cc291
|
|
| BLAKE2b-256 |
e508675c418f808996c4cf9276e5543ebd91c6d06e1f3e1940b75088c939e9a3
|
File details
Details for the file conpyguration-0.1.0a0-py3-none-any.whl.
File metadata
- Download URL: conpyguration-0.1.0a0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed891b400400c4bede27e0cdef1ccd1c4da09859dea000bc3f391f0c1e84e624
|
|
| MD5 |
952b50d566c9ec4af128f81a5320ebd5
|
|
| BLAKE2b-256 |
bc8078b8e62fa97e18081b0b93aeca26db2677d8736fdee206eff4f3e86de586
|