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

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 Define An Alias For A Type In Python For Type Hinting

How to define an alias for a type to use type hint: import typing type Ticker str # How to do this?… Read more How To Define An Alias For A Type In Python For Type Hinting

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"

In Python Type-hinting, How Can I Make An Argument Accept Any Subclass Of A Base Class?

I have a function that looks a bit like this. I want the function to accept any subclass of io.IOBa… Read more In Python Type-hinting, How Can I Make An Argument Accept Any Subclass Of A Base Class?

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

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