https://bugs.kde.org/show_bug.cgi?id=369363
Bug ID: 369363 Summary: Type not inferred when iterating objects with __next__ Product: kdev-python Version: 5.0.1 Platform: Other OS: Linux Status: UNCONFIRMED Severity: normal Priority: NOR Component: Language support Assignee: m...@svenbrauch.de Reporter: nicolas.alva...@gmail.com If I have a generator implemented as a function, iterating over it with a for loop (or list comprehension) correctly deduces the type of the item variable: def gen1(): yield "blah" for item1 in gen1(): print(item1) Here, KDevelop knows item1 is a str, because that is what gen1 yields. However, if I do the same with a class that has a custom __next__ method, the type is not deduced: class Gen2: def __iter__(self): return self def __next__(self): return "blah" gen2 = Gen2() for item2 in gen2: print(item2) The tooltip shows item2 as 'mixed', its attributes are not highlighted or completed, etc. This affects a few built-in types, such as I/O classes that yield strings (lines) when iterated. (In many cases the definitions in documentation_files don't have a __next__ and they should, but the point of this bug is that adding the missing __next__ makes no difference) -- You are receiving this mail because: You are watching all bug changes.