Skip to content

Assignment to next in class body of Iterator elicits error (in PY2 mode) #2503

Description

@gvanrossum

Since #2380 was merged, the following example elicits an error when type-checked in Python 2 mode:

from typing import Iterator
class A: pass
class X(Iterator[A]):
  def __next__(self):
    # type: () -> A
    pass
  next = __next__

The error comes from the code added by #2380:

__tmp__.py: note: In class "X":
__tmp__.py:7: error: Incompatible types in assignment (expression has type Callable[[X], A], variable has type Callable[[Iterator[A]], A])

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fields

    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