Skip to content

[red-knot] design how we want to use sub-diagnostics #16241

@carljm

Description

@carljm

Description

In some cases, an operation can fail because some sub-operation failed, and this can be somewhat arbitrarily recursive (though usually not too deep). For example, we tried to call a union, which failed because one element of the union was not callable, because it is an instance of a type which has a __call__ method which may not be bound.

Currently we have to choose between either giving the details of the "inner" failure or giving useful "outer" context. In some of these cases, we may want to use "sub-diagnostics" where we can give an outer failure (e.g. with the full union type) as well as "inner" details on the root cause. Both pyright and mypy do this to some extent.

We'll need to figure out some principles around when and where to do this, how we can render it, and at what level of nesting we need to cut it off.

See #16161 (comment) for some more detailed discussion.

Metadata

Metadata

Assignees

Labels

diagnosticsRelated to reporting of diagnostics.tyMulti-file analysis & type inference

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions