11from enum import StrEnum
22from typing import Any , Literal , TypedDict
33
4- __version__ = "1.0.0 "
4+ __version__ = "1.0.1 "
55
66
7- # Right now, only ON-DEMAND mode is supported!
7+ # Right now, only ON-DEMAND/PAY_PER_REQUEST mode is supported!
88class BillingMode (StrEnum ):
9+ """An `Enum` class representing the billing mode of tables. \
10+
11+ **NOTE**: Right now, only `PAY_PER_REQUEST` is supported!
12+
13+ Args:
14+ StrEnum (_type_): The base enum class.
15+
16+ Returns:
17+ _type_: The enum member, representing the billing mode.
18+ """
919 PAY_PER_REQUEST = "PAY_PER_REQUEST"
1020 # PROVISIONED = "PROVISIONED"
1121
1222 def __str__ (self ) -> str :
23+ """Return the billing mode directly as a string.
24+
25+ Returns:
26+ str: The billing mode's string representation.
27+ """
1328 return self .value
1429
1530
1631class __ConfigMap (TypedDict ):
32+ """A `TypedDict`, enforcing static types on config keys.
33+
34+ Args:
35+ TypedDict (_type_): The base type.
36+ """
1737 DATABASE_REGION : str
1838 # DATABASE_BILLING_MODE: BillingMode
1939 DATABASE_BILLING_MODE : Literal [BillingMode .PAY_PER_REQUEST ]
@@ -23,6 +43,16 @@ class __ConfigMap(TypedDict):
2343
2444
2545def __create_config ():
46+ """Create a new config instance for this python process. \
47+ Can be modified using this module's `get` and `set` methods.
48+
49+ Raises:
50+ KeyError: If the key is not known or not defined.
51+ TypeError: If the config expected another type for a certain key.
52+
53+ Returns:
54+ _type_: The created `get` and `set` methods.
55+ """
2656 __config_map : __ConfigMap = {
2757 "DATABASE_REGION" : "eu-central-1" ,
2858 "DATABASE_BILLING_MODE" : BillingMode .PAY_PER_REQUEST ,
@@ -32,9 +62,28 @@ def __create_config():
3262 }
3363
3464 def get (key : str , default : Any = None ) -> Any :
65+ """Get a value from the config dict.
66+
67+ Args:
68+ key (str): The unique key specifying the configuration option.
69+ default (Any, optional): A default value that is being returned when the key is not found. Defaults to None.
70+
71+ Returns:
72+ Any: The configuration value.
73+ """
3574 return __config_map .get (key , default )
3675
3776 def set (key : str , value : Any ) -> None :
77+ """Set/Change a value inside of the config dict.
78+
79+ Args:
80+ key (str): The unique key specifying the configuration option.
81+ value (Any): The new value this configuration option will be changed to.
82+
83+ Raises:
84+ KeyError: If the key is not defined or invalid.
85+ TypeError: If the value's type does not match the options expected type.
86+ """
3887 if key not in __config_map :
3988 raise KeyError (f"Unknown config key: { key } " )
4089 expected_type = type (__config_map [key ]) # type: ignore[literal-required]
0 commit comments