Skip to content

Improve hint for unresolved-import diagnostic #457

@MichaReiser

Description

@MichaReiser

astral-sh/ruff#18207 added a hint to the unresolved-import diagnostic, suggesting users to correctly configure their venv. While useful, I think we could do better by:

  • Adding a note (or sub diagnostic?) explaining where ty searched for said import (which search paths are configured?)
    • first-party (if any): src.root
    • third-party: enviroment.python: Ideally, with an information how we detected said environment and how they could customize it
    • extra search paths (if any)
    • standard library (typeshed path)
  • Add a note if there's no third-party import search path, hinting users to how they can configure it

I'm not sure how the best rendering looks like. You'll have to do some exploration on how to query and present the information to the user, so that it's useful.

We should also replace the URL to the documentation and use a redirect (I can set this up)

Metadata

Metadata

Assignees

No one assigned

    Labels

    diagnosticsRelated to reporting of diagnostics.help wantedContributions especially welcomeimportsModule resolution, site-packages discovery, import-related diagnostics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions