Skip to content

Commit 3780b0a

Browse files
committed
Allow len() with a Tuple argument
Fixes #158.
1 parent 535ae11 commit 3780b0a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

mypy/test/data/pythoneval.test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,3 +838,9 @@ import typing
838838
'x'.count('x')
839839
'x'.count(u'x')
840840
[out]
841+
842+
[case testLenOfTuple]
843+
import typing
844+
print(len((1, 'x')))
845+
[out]
846+
2

stubs/3.2/builtins.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,10 @@ def isinstance(o: object, t: tuple) -> bool: pass
964964
def issubclass(cls: type, classinfo: type) -> bool: pass
965965
# TODO perhaps support this
966966
#def issubclass(type cld, classinfo: Sequence[type]) -> bool: pass
967+
@overload
967968
def len(o: Sized) -> int: pass
969+
@overload
970+
def len(o: tuple) -> int: pass
968971
def locals() -> Dict[str, Any]: pass
969972

970973
# TODO more than two iterables

0 commit comments

Comments
 (0)