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

Mypy Error Typevar With Value Restriction And Union Of Unions / Optional Cannot Pass Generic Container Type

So, the following example is obviously contrived but I tried to keep some verisimilitude to my actu… Read more Mypy Error Typevar With Value Restriction And Union Of Unions / Optional Cannot Pass Generic Container Type

How To Add Hint To A Factory Method?

I'm looking for a way to annotate return type of a factory function. It returns random child of… Read more How To Add Hint To A Factory Method?

Python: All Type Hints Errors In Subclass Constructure Seems Ignored

I have the following code with python type hints It has a bunch of errors. All erros in code are fo… Read more Python: All Type Hints Errors In Subclass Constructure Seems Ignored

Why Does Mypy Think Library Imports Are Missing?

When I run mypy it complains that modules cannot be found: sal@ahfang:~/workspace/ecs/cx-project-sk… Read more Why Does Mypy Think Library Imports Are Missing?