Skip to content

Give better error message if type inference fails because of unsatisfiable upper bound #5706

Open
@ilevkivskyi

Description

@ilevkivskyi

After #5699 in certain cases (see testWideOuterContextEmptyError) if type inference fails, mypy gives an obscure error like

Incompatible types in assignment (expression has type "List[<nothing>]", variable has type "List[str]")

This error message could be improved. Here are some ideas:

  • Record that we didn't use the outer context because of unsatisfied bound and add a note about this
  • (Probably better) If type variable with a bound is used in an invariant context and we can't infer a value, we currently infer C[<nothing>]. What if we'd instead inferred C[<bound>]?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions