Skip to content

Python: location of py/iter-returns-non-iterator can be confusing #1427

@s0

Description

@s0

See https://discuss.lgtm.com/t/python-false-positive-the-iter-method-of-iterable-class-xxx-does-not-return-an-iterator/2116

In the case where __iter__ returns an instance of a class that partially implements an iterator (e.g. implements __next__ but not __iter__), then the alert location and message can be confusing, as the problem actually lies with the definition of the iterator, and not the use of it.

As a suggested improvement, when returning an instance of a class that implements __next__ but not __iter__, the alert location should instead be the iterator class, and the message something like "This class is returned as an iterator {here}, but is missing a definition for __next__, so does not fully implement the iterator interface."

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions