Skip to content

Instantly share code, notes, and snippets.

@mpkocher
Last active February 23, 2021 02:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpkocher/bde6b775ab403b12e34dd388d2903863 to your computer and use it in GitHub Desktop.
Save mpkocher/bde6b775ab403b12e34dd388d2903863 to your computer and use it in GitHub Desktop.
inconsistent_types.py
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()
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