Skip to content

Instantly share code, notes, and snippets.

View gvanrossum's full-sized avatar

Guido van Rossum gvanrossum

View GitHub Profile
# Don't name this file html.py!
from __future__ import annotations
from typing import *
from dataclasses import dataclass
from html import escape
from html.parser import HTMLParser
@gvanrossum
gvanrossum / expander.py
Last active October 7, 2023 23:15
Expand variadic type variables
LIMIT = 5
BOUND = 'object'
def prelude(limit: int, bound: str) -> None:
print('from typing import Callable, Iterable, Iterator, Tuple, TypeVar, overload')
print('Ts = TypeVar(\'Ts\', bound={bound})'.format(bound=bound))
print('R = TypeVar(\'R\')')
for i in range(LIMIT):
print('T{i} = TypeVar(\'T{i}\', bound={bound})'.format(i=i+1, bound=bound))