[ty] fix display of top ParamSpec specialization (#22227)

## Summary

I only noticed this in the ecosystem report of
https://github.com/astral-sh/ruff/pull/22213 after merging it. The
change to displaying `Top[]` wrapper around the entire signature instead
of just the parameters had the side effect of not showing it at all when
displaying a top ParamSpec specialization. This PR fixes that.

Marking internal since this is a fixup of a not-released PR.

## Test Plan

Added mdtest that fails without this PR.
This commit is contained in:
Carl Meyer
2025-12-27 11:14:22 -08:00
committed by GitHub
parent 6d5fb09e92
commit 55c8707be6
2 changed files with 38 additions and 1 deletions

View File

@@ -1600,10 +1600,16 @@ impl<'db> FmtDetailed<'db> for DisplayCallableType<'_, 'db> {
match self.signatures.overloads.as_slice() {
[signature] => {
if matches!(self.kind, CallableTypeKind::ParamSpecValue) {
if signature.parameters().is_top() {
f.write_str("Top[")?;
}
signature
.parameters()
.display_with(self.db, self.settings.clone())
.fmt_detailed(f)?;
if signature.parameters().is_top() {
f.write_str("]")?;
}
} else {
signature
.display_with(self.db, self.settings.clone())