If I have a function like this:
def foo(name, opts={}): pass
And I want to add type hints to the parameters, how do I do it? The way I as
If you're using typing (introduced in Python 3.5) you can use typing.Optional, where Optional[X] is equivalent to Union[X, None]. It is used to signal that the explicit value of None is allowed . From typing.Optional:
typing.Optional
Optional[X]
Union[X, None]
None
def foo(arg: Optional[int] = None) -> None: ...