Skip to content

Cannot infer type argument when mixing int and float #2035

Closed
@JukkaL

Description

@JukkaL

Mypy complains about this code, even though it looks fine to me:

from typing import Sequence, TypeVar

_T = TypeVar('_T')

def bisect_left(a: Sequence[_T], x: _T) -> int: ...

bisect_left([1, 2, 3], 5.391)  #  Cannot infer type argument 1 of "bisect_left"

This doesn't seem to be related to promotions, as it also happens with user-defined types:

class A: pass
class B(A): pass

bisect_left([B()], A())   # same error

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions