This commit is contained in:
2025-04-13 01:11:44 -03:00
parent bef51f492a
commit 273c580139
20 changed files with 552 additions and 29 deletions

View File

@@ -14,7 +14,7 @@ from boto3.dynamodb.types import TypeDeserializer, TypeSerializer
from botocore.exceptions import ClientError
from .dateutils import now, timestamp
from .funcs import omit
from .funcs import omit, pick
TZ = os.getenv('TZ', 'UTC')
PK = os.getenv('DYNAMODB_PARTITION_KEY', 'pk')
@@ -75,8 +75,9 @@ else:
def __new__(
cls,
keyparts: str | tuple[str, ...],
*,
/,
prefix: str | None = None,
*,
delimiter: str = '#',
) -> str:
if isinstance(keyparts, str):
@@ -90,8 +91,9 @@ else:
def __init__(
self,
keyparts: str | tuple[str, ...],
*,
/,
prefix: str | None = None,
*,
delimiter: str = '#',
) -> None:
# __init__ is used to store the parameters for later reference.
@@ -258,7 +260,7 @@ class KeyPair(Key):
match obj:
case dict():
pair = obj.values()
pair = pick((PK, SK), obj).values() # Gotta keep them in order
case _:
pair = obj