[ty] Tell the user why we inferred the Python version we inferred by AlexWaygood 路 Pull Request #18082 路 astral-sh/ruff (original) (raw)

Summary

I'm blaming @MichaReiser for this. He said it would be easy in #18068 (comment) and... it wasn't 馃槅

This PR propagates the origin of the inferred Python version (CLI flag, pyproject.toml, ty.toml, etc.) from the ty_project crate to the ty_python_semantic crate. (Specifically, a new python_version_source field is added to the ty_python_semantic::program::Program struct.) Having the origin of the Python version available allows us to add subdiagnostics that annotate the specific part of the config file that led us to infer a certain Python version.

A screenshot to demonstrate this in action:

image

Test Plan

I added integration tests to the ty crate.