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 enum import Enum | |
from fastapi import FastAPI, Depends, HTTPException, Query | |
from pydantic import BaseModel, ValidationError | |
app = FastAPI() | |
class Number(float, Enum): |
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
docker run -it python:3.10.0a6-buster |
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
def fun([head, *tail]): … | |
def fun([end]): … | |
def fun(element): … |
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
status_code = 200 | |
match status_code: | |
case 404: print("Not found") | |
case 200: print("Ok") | |
case _: raise ValueError("Can't handle status code") | |
# Prints "Ok" |
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
Python 3.10.0a6+ (heads/master:87f649a409, Mar 11 2021, 16:29:20) [Clang 12.0.0 (clang-1200.0.32.29)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> status_code = 200 | |
>>> match status_code: | |
... case 404: print("Not found") | |
... case 200: print("Ok") | |
... case _: raise ValueError("Can't handle status code") | |
... | |
Ok | |
>>> |
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, TypeVar | |
class Base: | |
common: str = "Data" | |
class ImportModel(Base): | |
pass |
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 sh | |
sed -e 's/export interface components {//' \ | |
-e 's/schemas: {//' -e 's/ }\n}$//' \ | |
-e '$d' models/api.ts \ | |
| sed -e '$d' \ | |
| sed -E 's/[[:space:]]*([A-Z].*)+:[[:space:]]*{/export interface \1 {/' \ | |
| sed -E "s/components\['schemas'\]\['([[:alpha:]_[:digit:]]+)'\]/\1/" > models/api-interface.ts && \ | |
rm models/api.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
from typing import Any | |
from rich.console import Console, ConsoleOptions, RenderResult | |
from rich.markdown import Markdown, Heading, Text | |
class SubtleHeading(Heading): | |
def __init__(self, level): | |
# Defering all headings by one level to avoid the borderd box for H1, hence level 2 is max | |
super().__init__(level + 1) |
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 [pydantic [BaseModel]]) | |
(defn create-attribute [type name] | |
`(^~type ~name)) | |
(defn create-attributes [attributes] | |
(map (fn [x] (create-attribute (unpack-iterable x))) | |
attributes)) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder