Speaker

Luka Sterbic

Material

Note

Are Python types Pythonic?

import this

>>> Explicit is better than implicit.

>>> Readability counts

>>> In the face of ambiguity, refuse the temptation to guess.

If nothing else, because Guido said so ๐Ÿ˜†

Type 101

  • Collection, Union, Optional, Type
from typing import Type, TypeVar

class BaseClass:
    pass

class DerivedClass(BaseClass):
    pass

T = TypeVar("T", bound=BaseClass)

def factory(clazz: Type[T]) -> T:
    return claszz()

Tool

GitHub - Instagram/MonkeyType: A system for Python that generates static type annotations by collecting runtime types

Share on: Twitter โ„ Facebook โ„ Email


Published

Category

PyCon AU 2018

Tags

Contact