Is it possible in python typing to restrict a function argument to be not a literal? My usecase is the following. I have code like this example. class Test(Enum): A = 'A' B = 'B' @overload def test(test: Literal[Test.A], foo: int) -> None: ... @overload def test(test: Literal[Test.B], foo: str) -> None: ... def test(test: Test, foo: int | str) -> None: print(test) print(foo) This effectively makes the type of the argument foo dependent on the enum value of argument test. Lets assume that this makes sense for some implementation of the function. The problem arises when I want to supply a variable as argument to the function test. Since a variable is not a literal mypy will complain about the wrong type and a missing overload. One option to solve this is an additional overload like so: @overload def test(test: Test, foo: int | str) -> None: ... Then code giving a variable for parameter test will type check. But wrong code like for example test(Test.A, 'abc') will also type check. If will not match the overload given for the literal Test.A but it will match the additional overload. Is it possible to restrict the additional overload only to non Literals? My goal is that the type checker will spot an error if args are given as literals, but not for variables since this is out of reach for the type checker. In that case it must be ensured by the caller that only appropriate arguments are passed. If there is a complete other approach to write that code for the type checker this would also be a solution to my problem. Continue reading...