This might sound unreasonable but right now I need to negate a type annotation. I mean something like this
an_int : Not[Iterable]
a_string: Iterable
This is because I wrote an overload for a function and mypy does not understand me. My function looks like this...
@overload
def iterable(o: Iterable) -> Literal[True] : ...
@overload
def iterable(o: Any) -> Literal[False] : ...
def iterable(o: Iterable|Any) -> Literal[True, False] :
return isinstance(o, Iterable)
But mypy complains that overload 1 overlaps overload 2 and returns incompatible type.
A negating type annotation could easily solve this by using Not[Iterable]
instead of Any
in overload 2.
Does anyone know how to solve this problem?