Reputation: 9114
Without : int
this program runs fine:
#!/usr/bin/env python3
import typing # not needed
def foo():
return (1,2,3)
def bar(i = foo()[0]: int): # adding ': int' breaks the Universe
return i
print(bar())
Upvotes: 1
Views: 51
Reputation: 7747
You've got it backwards, the type hint goes after the param, not after the default:
def bar(i: int = foo()[0]):
Upvotes: 3