This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_marked(obj): | |
"""Returns the set of marked columns for an object""" | |
return set(_obj_tracking[obj]["marked"]) | |
def get_marked_or_default(obj): | |
marked = get_marked(obj) | |
for column in obj.Meta.columns: | |
if column.default is not missing: | |
marked.add(column) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
_trace_installed = False | |
def install_trace_logger(): | |
global _trace_installed | |
if _trace_installed: | |
return | |
level = logging.TRACE = logging.DEBUG - 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import functools | |
import json | |
import secrets | |
import aiohttp | |
from concurrent.futures import ALL_COMPLETED | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bottom | |
from collections import defaultdict | |
_handlers = defaultdict(list) | |
def attach_handlers(client: bottom.Client) -> bottom.Client: | |
for event, funcs in _handlers.items(): | |
for func_builder in funcs: | |
client.on(event, func=func_builder(client)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Any, Callable, Iterable | |
def noop(next_handler: Callable, *args: Any, **kwargs: Any) -> None: | |
pass | |
def process(handlers: Iterable[Callable], *args: Any, **kwargs: Any) -> None: | |
next_args = args | |
next_kwargs = kwargs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bloop import Engine | |
from bloop.ext._lambda import unpack | |
from boto3 import Session | |
from my_models_script import MyModel | |
primary = Engine() | |
session = Session(region_name="us-east-1") | |
backup = Engine( | |
dynamodb=session.client("dynamodb"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Any, Dict, List, NamedTuple, Optional, Tuple, TypeVar, Generic, Type | |
T = TypeVar("T") | |
class Field(Generic[T]): | |
key: str | |
t: Type[T] | |
readonly: bool | |
def __init__(self, t: Type[T], readonly: bool=True) -> None: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import inspect | |
from typing import Callable, TypeDef | |
T = TypeDef("T") | |
def defer(func: Callable[[], T]) -> T: | |
sig = inspect.signature(func) | |
base = sig.return_type | |
double_entry = False | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2016 Joe Cross | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bloop import List | |
# Uses inner type's serialization for single values | |
# ie. List(String).contains("one value") | |
class List(List): | |
def _dump(self, value, *, context=None, **kwargs): | |
if value is None: | |
return value | |
if not isinstance(value, list): |