Showing posts with the label typing

[FIXED] Python isinstance of class within same class' definition

Issue I want to do something like class my_class: def __add__(self, other: "my_class"…

[FIXED] How to create customizable Python type

Issue I would like to create custom Python type hint that would effectively be MyType = Dict[str, …

[FIXED] How can I mention there should return any child of parent class in Python?

Issue class Element: def __call__(self, *args, **kwargs): print('Hello') …

[FIXED] Numpy Typing with specific shape and datatype

Issue Currently i'm trying to work more with numpy typing to make my code clearer however i'…

[FIXED] Typing dataclass that can only take enum values

Issue I have a dataclass that can take values that are part of an enum. class MyEnum(Enum): A …

[FIXED] How to use Dict to specify type-hint in Python

Issue I have a function which will return a dictionary like: from typing import Dict def foo() -&…

[FIXED] How to annotate a type that is a combination of multiple duck-types?

Issue Let's say I want to annotate the parameter to a function, and it should satisfy both typi…

[FIXED] How to inspect return type of Callable

Issue Let's say I have something like the following: import inspect from collections.abc impor…

[FIXED] How to define a TypedDict class with keys containing hyphens

Issue How can I create a TypedDict class that supports keys containing hyphens or other characters …

[FIXED] Determining if object is of typing.Literal type

Issue I need to check if object is descendant of typing.Literal, I have annotation like this: Game…