Skip to content Skip to sidebar Skip to footer
Showing posts with the label Mypy

How Can I Add Python Type Annotations To The Flask Global Context G?

I have a decorator which adds a user onto the flask global context g: class User: def __init__(… Read more How Can I Add Python Type Annotations To The Flask Global Context G?

How Can I Keep Imports Lightweight And Still Properly Type Annotate?

Tensorflow is a super heavy import. I want to import it only when it's needed. However, I have … Read more How Can I Keep Imports Lightweight And Still Properly Type Annotate?

How To Use Reveal_type In Mypy

I have read that I can reveal the type of variables by using a function called reveal_type, but I c… Read more How To Use Reveal_type In Mypy

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?

How To Use Typeshed With Mypy?

I cloned typeshed but I can't figure out how to tell mypy to use the type hints it contains, I … Read more How To Use Typeshed With Mypy?

Python Type Hints And Context Managers

How should a context manager be annotated with Python type hints? import typing @contextlib.contex… Read more Python Type Hints And Context Managers