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 contextvars import Context, ContextVar, copy_context | |
| from typing import Any | |
| def _set_cvar(cvar: ContextVar, val: Any): | |
| cvar.set(val) | |
| class CaptureContext: | |
| """Capture changes to the Context within the block. |
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 contextlib import contextmanager | |
| from dataclasses import dataclass, field | |
| from logging import Filter, Formatter, Handler, Logger, LogRecord | |
| from logging import config as logging_config_mod | |
| from logging import getLogger | |
| from typing import Generator, List, Optional, Sequence, Union | |
| @dataclass(frozen=True) | |
| class CapturedRecord: | |
| records: List[LogRecord] = field(default_factory=list) | |
| output: List[str] = field(default_factory=list) |
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 typing import Awaitable, Callable | |
| from fastapi import FastAPI, Request, Response | |
| from fastapi.exceptions import HTTPException | |
| from opentelemetry import trace | |
| from opentelemetry.sdk.trace import TracerProvider | |
| from opentelemetry.propagate import inject | |
| from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor | |
| trace.set_tracer_provider(TracerProvider()) |
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 __future__ import annotations | |
| from dataclasses import dataclass as dataclass | |
| from dataclasses import field | |
| from typing import Any, Dict, List, Literal, Mapping, Optional, Union | |
| ParameterLocations = Literal["header", "path", "query", "cookie"] | |
| PathParamStyles = Literal["simple", "label", "matrix"] | |
| QueryParamStyles = Literal["form", "spaceDelimited", "pipeDelimited", "deepObject"] | |
| HeaderParamStyles = Literal["simple"] |
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 typing | |
| from dataclasses import dataclass | |
| @dataclass | |
| class BodyBase: | |
| content_type: str | |
| @dataclass |
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 __future__ import annotations | |
| import cProfile | |
| import pstats | |
| from collections import deque | |
| from dataclasses import dataclass, field | |
| from random import Random | |
| from timeit import default_timer | |
| from typing import Awaitable, Callable, Deque, Iterable, List, Optional, Protocol, Union |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| use std::cmp; | |
| use std::hash; | |
| use std::collections::HashSet; | |
| use std::os::raw::c_int; | |
| use pyo3::prelude::*; | |
| use pyo3::ffi; | |
| use pyo3::conversion::{AsPyPointer}; | |
| use pyo3::{pyobject_native_type_base,pyobject_native_type_info,pyobject_native_type_extract,PyNativeType}; | |
| use pyo3::types::{PyString}; |
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
| use std::cmp; | |
| use std::collections::HashMap; | |
| use std::collections::hash_map::Entry; | |
| use std::hash; | |
| use pyo3::prelude::*; | |
| use pyo3::types::{PyTuple}; | |
| // We can't put a Py<PyAny> directly into a HashMap key |
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
| use std::cmp; | |
| use std::hash; | |
| use pyo3::basic::CompareOp; | |
| use pyo3::prelude::*; | |
| // We can't put a Py<PyAny> directly into a HashMap key | |
| // So to be able to hold references to arbitrary Python objects in HashMap as keys | |
| // we wrap them in a struct that gets the hash() when it receives the object from Python |