When typing my python functions PEP-484 style, how can I make the return type depend on the literal value of a parameter?
E.g., take this trivial function which adds 1 to the first element in the list, and optionally returns the list if the second parameter is True.
def add_one(x: list[int], return_result: bool):
x[0] += 1
if result_result:
return x
By default the return type will be inferred to be None | list[int] but I want it to be just None if literal False is passed or list[int] if literal True is passed as the second parameter.