Skip to content Skip to sidebar Skip to footer
Showing posts with the label Type Hinting

Pep-484 Type Annotations With Own Types

PEP-484 provides semantics for type annotations. These are geared very much towards a) documentatio… Read more Pep-484 Type Annotations With Own Types

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?

Class Decorator Compatible For Mypy

Say I have the following simple example without any typehints: def wrapper(cls): class Subclass… Read more Class Decorator Compatible For Mypy

Type Hint For Return Value In Subclass

I am writing a CustomEnum class in which I want to add some helper methods, that would then be avai… Read more Type Hint For Return Value In Subclass

The Type Of A Variable That Can Be Implicitly Checked For "zeroness" Or "emptiness"

I have a function that receives a variable x and checks for it's 'zeroness' or 'emp… Read more The Type Of A Variable That Can Be Implicitly Checked For "zeroness" Or "emptiness"

Using Type Hints To Translate Python To Cython

Type Hints now are available in Python 3.5 version. In the specification (PEP 484) the goals (and t… Read more Using Type Hints To Translate Python To Cython

How To Hint At Number *types* (i.e. Subclasses Of Number) - Not Numbers Themselves?

Assuming I want to write a function that accepts any type of number in Python, I can annotate it as… Read more How To Hint At Number *types* (i.e. Subclasses Of Number) - Not Numbers Themselves?

PEP 484: Exclusive Type For Type Hint

Could I specify exclusive type? Something like this: def foo(bar: Not[str]) -> None: assert … Read more PEP 484: Exclusive Type For Type Hint