The following is valid typed code and my personal favorite WTF:
def func() -> int:
return True
Because: https://github.com/satwikkansal/wtfpython/blob/master/README...I understand the decision that was made in the python 2 era. Nowadays Boolean shouldn't be a subtype of `int`. It goes against the zen of python:
- Explicit is better than implicit.
It actually happened because I was using the new walrus operator (which I like).
def calc(input: int) -> int:
return input // 3
def func(input: int) -> Iterator[int]:
while input:= calc(input) > 0:
yield input
*edit: code layout