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?

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

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 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?

Type Hinting Sqlalchemy Query Result

I can't figure out what kind of object a sqlalchemy query returns. entries = session.query(Foo.… Read more Type Hinting Sqlalchemy Query Result

Typing Function When Decorator Change Return Type

how to correctly write types for the function whose return type is modified by decorator ? Simple … Read more Typing Function When Decorator Change Return Type

Exclude Type In Python Typing Annotation

I wrote the following function: def _clean_dict(d): return {k: v for k, v in d.items() if v is … Read more Exclude Type In Python Typing Annotation

Mypy And Attrs: Errors Typechecking Lists Of Subclasses

I have a message container that can contain different kinds of messages. For now, there are only te… Read more Mypy And Attrs: Errors Typechecking Lists Of Subclasses