Skip to content Skip to sidebar Skip to footer
Showing posts with the label Type Hinting

Class Decorator Compatible For Mypy

Say I have the following simple example without any typehints: def wrapper(cls): class Subclass… Read more Class Decorator Compatible For Mypy

Typehint Importing Module Dynamically Using Importlib

Give something as follows: import importlib module_path = 'mod' mod = importlib.import_mod… Read more Typehint Importing Module Dynamically Using Importlib

What Is The Difference Between Typevar And Newtype?

TypeVar and NewType seem related but I'm not sure when I'm supposed to use each or what the… Read more What Is The Difference Between Typevar And Newtype?

Variable Annotations On A Class

I'm trying to build up an object graph in some code where I'm using type hint on class attr… Read more Variable Annotations On A Class

How Do I Avoid Type Errors When Internal Function Returns 'union' That Could Be 'none'?

I've been running into a bit of weirdness with Unions (and Optionals, of course) in Python - na… Read more How Do I Avoid Type Errors When Internal Function Returns 'union' That Could Be 'none'?

How To Make Mypy Complain About Assigning An Any To An Int

mypy --strict dutifully complains about the following code: from typing import Any, Dict def main(… Read more How To Make Mypy Complain About Assigning An Any To An Int