Created
October 18, 2022 14:29
-
-
Save Kludex/df69ce8194e68958256bb180512de85a to your computer and use it in GitHub Desktop.
Mandatorily have a parameter, either a or b.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
from typing import overload | |
@overload | |
def potato(a: int, b: None = None) -> int: | |
... | |
@overload | |
def potato(*, a: None = None, b: int) -> int: | |
... | |
def potato(a: int | None = None, b: int | None = None) -> int: | |
return a or b | |
potato(None) # type: ignore[call-overload] | |
potato(1) | |
potato(b=1) | |
potato() # type: ignore[call-overload] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is wrong. How can I make it compliant with the description?