mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 13:04:46 +08:00
builtins: accept old-style iterables to iter (#7817)
This commit is contained in:
14
test_cases/stdlib/builtins/test_iteration.py
Normal file
14
test_cases/stdlib/builtins/test_iteration.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from typing import Iterator
|
||||
from typing_extensions import assert_type
|
||||
|
||||
|
||||
class OldStyleIter:
|
||||
def __getitem__(self, index: int) -> str:
|
||||
return str(index)
|
||||
|
||||
|
||||
for x in iter(OldStyleIter()):
|
||||
assert_type(x, str)
|
||||
|
||||
assert_type(iter(OldStyleIter()), Iterator[str])
|
||||
assert_type(next(iter(OldStyleIter())), str)
|
||||
Reference in New Issue
Block a user