-
-
Save mpkocher/bde6b775ab403b12e34dd388d2903863 to your computer and use it in GitHub Desktop.
inconsistent_types.py
This file contains 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 typing import Optional | |
def log(number: int = None, commit: str = None) -> list[str]: | |
args = ["log"] | |
if number: | |
args.extend(["--number", str(number)]) | |
return args | |
def log2(number: int = Optional[int], commit: str = Optional[str]) -> list[str]: | |
args = ["log"] | |
if number: | |
args.extend(["--number", str(number)]) | |
return args | |
def demo() -> int: | |
print(log()) | |
print(log(0)) | |
print(log(1)) | |
return 0 | |
demo() |
This file contains 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
mypy 0.812 | |
inconsistent_types.py:11: error: Incompatible default for argument "number" (default has type "object", argument has type "int") | |
inconsistent_types.py:11: error: Incompatible default for argument "commit" (default has type "object", argument has type "str") | |
Found 2 errors in 1 file (checked 1 source file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment