Skip to content

Doesn't work #3

@zenna

Description

@zenna

This doesn't seem to work?

Running your examples:

@overload
def biggest(items: Iterable[int]):
    return max(items)

@overload
def biggest(items: Iterable[str]):
    return max(items, key=len)

biggest([2, 0, 15, 8, 7])

Returns error

<ipython-input-3-4c7948311942> in biggest(items)
      5 @overload
      6 def biggest(items: Iterable[str]):
----> 7     return max(items, key=len)

TypeError: object of type 'int' has no len()

Or with my own example:

@overload
def f(x: int):
  return x - 100

@overload
def f(x: str):
  return "Hello %s" %s

print(f(3))
print(f("You"))
Traceback (most recent call last):
  File "testoverload.py", line 12, in <module>
    print(f(3))
  File "overload.py", line 184, in f
    raise TypeError('invalid call argument(s)')
TypeError: invalid call argument(s)

I'm using python3.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions