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 hashlib | |
import os | |
import httpx | |
from httpx_auth import OAuth2AuthorizationCode | |
from pydantic import BaseSettings | |
from rich.console import Console | |
console = Console() |
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 starlette.datastructures import MutableHeaders | |
BROWSER_SYNC_SCRIPT =b"<script>console.log('Hi there!');</script>" | |
class InjectScriptMiddleware: | |
def __init__(self, app, script: bytes = BROWSER_SYNC_SCRIPT): | |
self.app = app | |
self.script = 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
from __future__ import annotations | |
from typing import overload | |
@overload | |
def potato(a: int, b: None = None) -> int: | |
... | |
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 TYPE_CHECKING | |
if TYPE_CHECKING: | |
from typing import Any, Callable, Generic, Literal, Protocol, Tuple, overload | |
from celery import Celery as _Celery | |
from celery import Task as _Task | |
from typing_extensions import TypeVarTuple, Unpack | |
Ts = TypeVarTuple("Ts") |
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
# Inspired by https://snyk.io/blog/best-practices-containerizing-python-docker/ | |
FROM python:3.10-slim | |
ENV PIP_NO_CACHE_DIR=off | |
RUN groupadd -g 999 python \ | |
&& useradd -r -u 999 -g python python \ | |
&& mkdir /usr/app \ | |
&& chown python:python /usr/app |
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 io | |
from typing import Any | |
import anyio | |
import ijson | |
from anyio.streams.buffered import BufferedByteReceiveStream | |
from anyio.streams.memory import MemoryObjectReceiveStream | |
from fastapi import FastAPI, Request, UploadFile | |
app = FastAPI() |
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 fastapi import APIRouter | |
router = APIRouter(prefix="/haha") | |
@router.get("/haha") | |
def home(): | |
... |
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 anyio | |
from fastapi import FastAPI | |
app = FastAPI() | |
@app.on_event("startup") | |
async def startup(): | |
limiter = anyio.to_thread.current_default_thread_limiter() |
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 typing import TYPE_CHECKING, Awaitable, Callable, TypedDict, TypeVar | |
from starlette.datastructures import MutableHeaders | |
from typing_extensions import NotRequired | |
if TYPE_CHECKING: | |
from asgiref.typing import ( | |
ASGI3Application, |
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
#!/usr/bin/env python3 | |
import subprocess | |
import sys | |
branch_name = subprocess.check_output("git rev-parse --abbrev-ref HEAD".split()).decode().strip() | |
jira_ticket = "-".join(branch_name.split("-")[:2]) | |
commit_msg = f"[{jira_ticket}] {sys.argv[1]}" | |
sys.argv[1] = commit_msg | |
gcmsg_args = sys.argv[1:] |