Skip to content

Instantly share code, notes, and snippets.

View alanbato's full-sized avatar
🐍
I like sneks.

Alan Velasco alanbato

🐍
I like sneks.
View GitHub Profile
@alanbato
alanbato / keybase.md
Created September 23, 2019 21:59
Keybase identification.

Keybase proof

I hereby claim:

  • I am alanbato on github.
  • I am alanbato (https://keybase.io/alanbato) on keybase.
  • I have a public key whose fingerprint is E1E6 D2FF 5759 6F34 6259 F195 3EE1 D8A2 85CE 4D6D

To claim this, I am signing this object:

@alanbato
alanbato / typecheck.py
Created February 5, 2018 22:17
A simple decorator-based runtime typechecker in python
def typecheck(func):
def wrapper(*args, **kwargs):
for argname, argvalue in zip(func.__code__.co_varnames,
args):
annotated_type = func.__annotations__[argname]
real_type = type(argvalue)
if not issubclass(real_type, annotated_type):
raise TypeError(f'expected:{annotated_type}\n'
f'got: {real_type}\n'
f'for argument {argname}')