Skip to content

range.index() takes exactly one argument #3660

Closed
@ilai-deutel

Description

@ilai-deutel

range.index() does not accept start and stop arguments (the documentation was fixed in python/cpython#13075):

>>> range(1, 9).index(1, 0, 1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: index() takes exactly one argument (3 given)

The stub file indicates that 3 arguments can be given. However, removing these extra arguments makes mypy complain about the signature of index being incompatible with supertype Sequence.

def index(self, value: int, start: int = ..., stop: Optional[int] = ...) -> int: ...

def index(self, x: Any, start: int = ..., end: int = ...) -> int: ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    stubs: false negativeType checkers do not report an error, but should

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions