This file contains hidden or 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
| # pip install sqlalchemy testing.postgresql | |
| # see also: https://blog.crunchydata.com/blog/message-queuing-using-native-postgresql | |
| import threading | |
| from contextlib import contextmanager | |
| from sqlalchemy import Column, Integer, String, create_engine | |
| from sqlalchemy.ext.declarative import declarative_base | |
| from sqlalchemy.orm import sessionmaker | |
| import testing.postgresql |
This file contains hidden or 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
| <style> | |
| .red { | |
| color: red; | |
| } | |
| </style> | |
| <div id="root"></div> | |
| <script> |
This file contains hidden or 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 os | |
| from typing import TypeVar | |
| import pydantic | |
| T = TypeVar("T") | |
| class _Missing: | |
| ... |
This file contains hidden or 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
| """Basically the same as pydifact, but with some changes: | |
| - Doesn't magically turn `[value] -> value`, each segment is a `list[list[str]]`. | |
| - Public singular `segment_to_raw()` function. | |
| - Easier to work out how the `Characters` configuration actually gets passed around. | |
| - Simplified and de-OO-ed code. Doesn't handle segment names any differently to other values. | |
| - Simpler style should make a rewrite-it-in-Rust (+PyO3) very easy if required. | |
| """ | |
| from __future__ import annotations |
This file contains hidden or 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 functools import cache | |
| from types import UnionType | |
| from typing import Annotated, Any, Literal, Union, get_args, get_origin | |
| import pydantic | |
| from pydantic.fields import PydanticUndefined as MISSING # type: ignore[attr-defined] | |
| def normalize(t: Any) -> Any: | |
| if get_origin(t) is Annotated: |
This file contains hidden or 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 ast | |
| from pathlib import Path | |
| depends_on = set[tuple[str, str]]() | |
| for p in (Path()).glob("*.py"): | |
| x = p.stem | |
| for node in ast.parse(p.read_text()).body: | |
| match node: | |
| case ast.ImportFrom(module=str(module), names=names): | |
| out = set[str]() |
This file contains hidden or 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 ast | |
| from pathlib import Path | |
| src = Path(...).read_text() | |
| for f in ast.parse(src).body: | |
| if isinstance(f, ast.FunctionDef): | |
| f.decorator_list = [] | |
| f.body = [] | |
| print(ast.unparse(f)) |
OlderNewer