Skip to content

Instantly share code, notes, and snippets.


Samuel Colvin samuelcolvin

View GitHub Profile
import polars as pl
ds = pl.read_parquet('page_views.parquet').sort('ts')
path_counts = (
ds.with_columns(pl.col('path').str.replace(r'^/(latest|dev-v\d|\d\.\d+)', ''))
pydantic-core: 01fdec6d2242fdf7205663d566be5ba990d1d459 - the custom-dataclass-validator branch
and pydantic: 519800fa5167a57681ba3b202503751aa0f17347 - the dataclasses-v2 branch
from typing import TypeVar
import pytest
from pydantic import BaseModel, ValidationError
samuelcolvin /
Last active March 8, 2023 20:55
An incomplete list of people in the Python community to follow on Twitter and Mastodon.

Python People

(Updated 2022-11-16 with suggestions from comments below, Twitter and Mastodon)

An incomplete list of people in the Python community to follow on Twitter and Mastodon.

With the risk that Twitter dies, I'd be sad to lose links to interesting people in the community, hence this list.

I would love you to comment below with links to people I've missed.

samuelcolvin /
Last active May 10, 2023 17:45
auto-generate assert statements in pytest
License: MIT
Copyright (c) 2022 Samuel Colvin.
## Usage
Once installed just add
View ansi-to-html.browser.js
require=(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
Object.defineProperty(exports, "__esModule", { value: true });
exports.decodeHTML = exports.decodeHTMLStrict = exports.decodeXML = void 0;
var entities_json_1 = __importDefault(require("./maps/entities.json"));
var legacy_json_1 = __importDefault(require("./maps/legacy.json"));
var xml_json_1 = __importDefault(require("./maps/xml.json"));
samuelcolvin /
Last active September 15, 2022 14:42
Check version script used before release.

To use simply run

VERSION_PATH='<your package dir>/' python <(curl -Ls
import asyncio
import base64
import json
from pathlib import Path
from httpx import AsyncClient
from bs4 import BeautifulSoup
from devtools import debug
View pydantic_core_pyodide.html
main {
display: flex;
pre {
margin: 0;
padding: 0;
code, #output {
white-space: pre-wrap;
View hypothesis_traceback.txt
➤ HYPOTHESIS_MAX_EXAMPLES=1000 pytest tests/ -s
Test session starts (platform: darwin, Python 3.10.5, pytest 7.1.2, pytest-sugar 0.9.4)
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=True warmup_iterations=100000)
rootdir: /Users/samuel/code/pydantic-core, configfile: pyproject.toml
plugins: benchmark-3.4.1, sugar-0.9.4, hypothesis-6.48.1, timeout-2.1.0, mock-3.8.1
timeout: 30.0s
timeout method: signal
timeout func_only: False
collecting ...
import os
from typing import TypeVar, Generic
import psutil
import pytest
from pydantic.generics import GenericModel
process = psutil.Process(os.getpid())