Python type hinting can’t exclude types. You can’t exclude None
s, str
s or any another type.
The only thing you can use to try to emulate None
exclusion is to use Union and write every type you are actually using in the dictionary.
More Related Contents:
- How can I specify the function type in my type hints?
- How to use type hints in python 3.6?
- Can I omit Optional if I set default to None?
- How to annotate function that takes a tuple of variable length? (variadic tuple type annotation)
- How do I type hint a method with the type of the enclosing class?
- What are variable annotations?
- How to specify multiple return types using type-hints
- Type hinting a collection of a specified type
- What are type hints in Python 3.5?
- Using the class as a type hint for arguments in its methods [duplicate]
- Type hint for a function that returns only a specific set of values
- How to specify “nullable” return type with type hints
- How should I use the Optional type hint?
- Type hints when unpacking a tuple?
- Python type hinting with exceptions
- Specify length of Sequence or List with Python typing module
- Type hinting / annotation (PEP 484) for numpy.ndarray
- A way to subclass NamedTuple for purposes of typechecking
- mypy, type hint: Union[float, int] -> is there a Number type?
- Name not defined in type annotation [duplicate]
- Python 3.5 type hinting does not result in an error
- Type annotations for Enum attribute
- Recursive Typing in Python 3.5+ [duplicate]
- What is the type hint for a (any) python module?
- Type annotations for *args and **kwargs
- How can I tell PyCharm what type a parameter is expected to be?
- What’s the difference between a constrained TypeVar and a Union?
- Using List/Tuple/etc. from typing vs directly referring type as list/tuple/etc
- “TypeError: ‘type’ object is not subscriptable” in a function signature
- Type hints in namedtuple