Skip to content

Argument type Top[list[Unknown]] does not satisfy upper bound Bottom[MutableSequence[Unknown]] of type variable Self #1196

@sharkdp

Description

@sharkdp

Summary

On astral-sh/ruff#18007, we see the following problem:

def f(obj: object):
    if isinstance(obj, list):
        obj.clear()
/home/shark/playground/test.py:8:9: error[invalid-argument-type] Argument to bound method `clear` is incorrect: Argument type `Top[list[Unknown]]` does not satisfy upper bound `Bottom[MutableSequence[Unknown]]` of type variable `Self`
/home/shark/playground/test.py:8:9: error[invalid-argument-type] Argument to bound method `clear` is incorrect: Expected `Self@clear`, found `Top[list[Unknown]]`

It looks like the upper bound is incorrect (Bottom[MutableSequence[Unknown]] instead of Top[MutableSequence[Unknown]].

Version

astral-sh/ruff#18007 (ed798a35ee8378d18c014a3c8c605981ca336ec9)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggenericsBugs or features relating to ty's generics implementation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions