Skip to content

Emit a diagnostic when widening a singleton with | Unknown #3254

@carljm

Description

@carljm

We've mostly removed gradual-guarantee unioning with Unknown now; the one place in which we still do it is if an attribute is not annotated and is initialized with = None (or another non-Literal singleton type). It's unlikely that the intent is for the attribute to only ever be None, so in this case we widen to None | Unknown.

For those who want to keep dynamic types out of their code, it would be nice to get a diagnostic when this occurs, to prompt adding an annotation.

This could be part of #622, but I think there might be advantages to making it a distinct diagnostic, or at least offering additional context in this case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions