Differentiating between "fields" and library methods/attributes
(Samuel Colvin)
See this discussion.
➤ HYPOTHESIS_MAX_EXAMPLES=1000 pytest tests/test_hypothesis.py::test_recursive_cycles -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()) |
(Samuel Colvin)
See this discussion.
from pathlib import Path | |
from watchfiles import watch | |
from devtools import debug | |
THIS_DIR = Path(__file__).parent | |
for changes in watch(THIS_DIR, debug=True): | |
debug(changes) |
#!/usr/bin/env python3 | |
import time | |
clocks = ['🕛', '🕐', '🕑', '🕒', '🕓', '🕔', '🕕', '🕖', '🕗', '🕘', '🕙', '🕚'] | |
# moves the cursor to the beginning of the line | |
# (3 columns back in this case is always enough) | |
reset_cursor = '\033[3D' | |
i = 0 | |
while True: |
javascript:(function(){ | |
const set_color = (cls, col) => document.querySelectorAll(cls).forEach(el => {el.parentNode.style.backgroundColor = col}); | |
set_color('.bg-ds-coverage-partial', '#ffa'); | |
set_color('.bg-ds-coverage-uncovered', '#fdd'); | |
})(); |
Usage is simply
VERSION_PATH=<package name> python <(curl -Ls https://bit.ly/set__version__)
This will set the __version__
variable in `
""" | |
Take the "Derived Property: ID_Start" section from https://www.unicode.org/Public/13.0.0/ucd/DerivedCoreProperties.txt | |
and save to "DerivedCoreProperties.txt" | |
""" | |
from pathlib import Path | |
def get_value(s: str) -> int: |
const log_el = document.getElementById('log') | |
function log(...messages) { | |
console.log(...messages) | |
log_el.innerText += '\n' + messages.map(m => JSON.stringify(m, null, 2)).join(' ') | |
} | |
function error(message) { | |
console.error(message) | |
log_el.innerText += '\n' + message |
from pathlib import Path | |
from httpx import AsyncClient | |
from aioaws.ses import SesConfig, SesClient, SesRecipient, SesAttachment | |
async def ses_demo(client: AsyncClient): | |
ses_client = SesClient(client, SesConfig('<access key>', '<secret key>', '<region>')) | |
message_id = await ses_client.send_email( | |
SesRecipient('sende@example.com', 'Sender', 'Name'), | |
'This is the subject', |