[ty] introduce multiline pretty printer (#19979)

Requires some iteration, but this includes the most tedious part --
threading a new concept of DisplaySettings through every type display
impl. Currently it only holds a boolean for multiline, but in the future
it could also take other things like "render to markdown" or "here's
your base indent if you make a newline".

For types which have exposed display functions I've left the old
signature as a compatibility polyfill to avoid having to audit
everywhere that prints types right off the bat (notably I originally
tried doing multiline functions unconditionally and a ton of things
churned that clearly weren't ready for multi-line (diagnostics).

The only real use of this API in this PR is to multiline render function
types in hovers, which is the highest impact (see snapshot changes).

Fixes https://github.com/astral-sh/ty/issues/1000
This commit is contained in:
Aria Desires 2025-08-19 13:31:44 -04:00 committed by GitHub
parent 59b078b1bf
commit c6dcfe36d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 793 additions and 106 deletions

View file

@ -19,6 +19,7 @@ pub use semantic_model::{
Completion, CompletionKind, HasDefinition, HasType, NameKind, SemanticModel,
};
pub use site_packages::{PythonEnvironment, SitePackagesPaths, SysPrefixPathOrigin};
pub use types::DisplaySettings;
pub use types::ide_support::{
ImportAliasResolution, ResolvedDefinition, definitions_for_attribute,
definitions_for_imported_symbol, definitions_for_name, map_stub_definition,