Skip to content

Improve error messages when narrowing fails #2221

@mtshiba

Description

@mtshiba

When strictly maintaining soundness, narrowing tends to produce results that are quite different from user intuition.
Users may not realize that this is due to the specifications of ty (or Python type system), and may consider it an incompleteness or a bug (e.g. #2215).
Therefore, if the cause of the error is thought to be a narrowing failure, it may be better to provide a hint as to why narrowing could not be applied.
Also, in some cases, alternatives can be suggested that make narrowing applicable (such as using is instead of ==, typing explicitly, or marking the class as non-inheritable with typing.final).

Metadata

Metadata

Assignees

No one assigned

    Labels

    diagnosticsRelated to reporting of diagnostics.narrowingrelated to flow-sensitive type narrowing

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions