I am using a simplified example, to show the problem. I have a function, could also be a method, which should accept only int
or bool
Any other type should be removed. I know how to input one type, I don't know how to input both. I have tried Sequence
from the typing
, but failed.See code below:
int_bool = TypeVar( "int_bool", int, bool)
def foo( a : Sequence[ int_bool ] ):
print( a )
foo( 1.1 )
>>> 1.1
It should error out, as 1.1 is neither int
nor bool