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

Remove Error From Mypy For Attributes Set Dynamically In A Python Class

I am using mypy to check my Python code. I have a class where I set dynamically some attributes and… Read more Remove Error From Mypy For Attributes Set Dynamically In A Python Class

Mypy Errors For Decorator W/ Arguments

I'm trying to do strict type checking with MyPy and I can't seem to get decorators with arg… Read more Mypy Errors For Decorator W/ Arguments

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?

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

Why Is Mypy Complaining About List Comprehension When It Can't Be Annotated?

Why does Mypy complain that it requires a type annotation for a list comprehension variable, when i… Read more Why Is Mypy Complaining About List Comprehension When It Can't Be Annotated?

How Do I Annotate A Type Which Has An Extra Attribute With Mypy?

I have an ast.UnaryOp object, but I manually added a parent attribute (see answer). How do I annota… Read more How Do I Annotate A Type Which Has An Extra Attribute With Mypy?

How Do I Make A Type Annotation For A List Of Subclass Instances, E.g To Concatenate Two Lists?

I want to iterate over List[A] and List[Subclass of A] and do the same loop. The best way I can see… Read more How Do I Make A Type Annotation For A List Of Subclass Instances, E.g To Concatenate Two Lists?

Incompatible Types In Assignment (expression Has Type "List[]", Variable Has Type (...)

Consider the following self-contained example: from typing import List, Union T_BENCODED_LIST = Un… Read more Incompatible Types In Assignment (expression Has Type "List[]", Variable Has Type (...)