Sometimes, suppressing errors is handy.
E.g. you see this:
try {
scrollableRef.update()
} catch {}| FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS base | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| libpq-dev \ | |
| pandoc \ | |
| && apt-get clean && rm -rf /var/lib/apt/lists/* | |
| FROM base AS install | |
| WORKDIR /app/ |
Sometimes, suppressing errors is handy.
E.g. you see this:
try {
scrollableRef.update()
} catch {}| GH_CONFIG := ~/.config/gh/hosts.yml | |
| GITHUB_USER := $(shell cat $(GH_CONFIG) | yq '.[].user' | xargs) | |
| GITHUB_TOKEN := $(shell cat $(GH_CONFIG) | yq '.[].oauth_token' | xargs) | |
| .PHONY: all | |
| build: | |
| docker build --build-arg=GITHUB_USER=$(GITHUB_USER) --build-arg=GITHUB_TOKEN=$(GITHUB_TOKEN) . |
| from sqlalchemy import Column, Float, Integer, String | |
| from sqlalchemy.orm import declarative_base | |
| Base = declarative_base() | |
| class Company(Base): | |
| id = Column(Integer, primary_key=True) | |
| name = Column(String) | |
| worth = Column(Float) |
| FROM python:3.10-slim AS install | |
| RUN apt-get update \ | |
| && apt-get upgrade -y \ | |
| && apt-get install -y --no-install-recommends curl \ | |
| && apt-get autoremove -y | |
| RUN pip install --upgrade pip | |
| WORKDIR /app/ | |
| # install poetry and keep the get-poetry script so it can be reused later. | |
| ENV POETRY_HOME="/opt/poetry" | |
| RUN curl https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py > get-poetry.py |
| from starlette.status import HTTP_200_OK | |
| from starlite import create_test_client | |
| from my_app.main import health_check | |
| def test_health_check(): | |
| with create_test_client(route_handlers=[health_check]) as client: | |
| response = client.get("/health-check") | |
| assert response.status_code == HTTP_200_OK |
| from starlite import Starlite, MediaType, get | |
| @get(path="/health-check", media_type=MediaType.TEXT) | |
| def health_check() -> str: | |
| return "healthy" | |
| app = Starlite(route_handlers=[health_check]) |
| from starlite import Starlite, LoggingConfig | |
| from my_app.users import UserController | |
| app = Starlite( | |
| route_handlers=[UserController], | |
| on_startup=[ | |
| LoggingConfig(loggers={ | |
| "my_app": { |
| from os import environ | |
| from sqlalchemy.ext.asyncio import AsyncEngine, create_async_engine | |
| # we first define a dependency. The dependency is a function or method (async or sync) whose return value will be injected | |
| def create_postgres_connection() -> AsyncEngine: | |
| postgres_connection_string = environ.get("POSTGRES_CONNECTION_STRING", "") | |
| if not postgres_connection_string: | |
| raise ValueError("Missing ENV Variable POSTGRES_CONNECTION_STRING") |
| from typing import List | |
| from pydantic import UUID4 | |
| from starlite import Controller, Partial, get, post, put, patch, delete | |
| from my_app.models import User | |
| class UserController(Controller): | |
| path = "/users" |