Fix Python – Python void return type annotation

In python 3.x, it is common to use return type annotation of a function, such as:
def foo() -> str:
return “bar”

What is the correct annotation for the “void” type?
I’m considering 3 options:

def foo() -> None:

not logical IMO, because None is not a type,

def foo() -> type(None):

using the best syntax I know for obtaining NoneType,


Fix Python – Type hinting a collection of a specified type

Using Python 3’s function annotations, it is possible to specify the type of items contained within a homogeneous list (or other collection) for the purpose of type hinting in PyCharm and other IDEs?
A pseudo-python code example for a list of int:
def my_func(l:list):

I know it’s possible using Docstring…
def my_func(l):

Fix Python – Python type hinting without cyclic imports

I’m trying to split my huge class into two; well, basically into the “main” class and a mixin with additional functions, like so: file:

class Main(object, MyMixin):
def func1(self, xxx): file:
class MyMixin(object):
def func2(self: Main, xxx): # <--- note the type hint ... Now, w....

Fix Python – How should I use the Optional type hint?

I’m trying to understand how to use the Optional type hint. From PEP-484, I know I can use Optional for def test(a: int = None) either as def test(a: Union[int, None]) or def test(a: Optional[int]).
But how about following examples?
def test(a : dict = None):
#print(a) ==> {‘a’: 1234}
#print(a) ==> None

def test(a : list = None):….

Fix Python – How to annotate types of multiple return values?

How do I use type hints to annotate a function that returns an Iterable that always yields two values: a bool and a str? The hint Tuple[bool, str] is close, except that it limits the return value type to a tuple, not a generator or other type of iterable.
I’m mostly curious because I would like to annotate a function foo() that is used to return ….

Fix Python – Type annotations for *args and **kwargs

I’m trying out Python’s type annotations with abstract base classes to write some interfaces. Is there a way to annotate the possible types of *args and **kwargs?
For example, how would one express that the sensible arguments to a function are either an int or two ints? type(args) gives Tuple so my guess was to annotate the type as Union[Tuple[int….