@@ -26,7 +26,6 @@ use pyrefly_types::callable::Param;
2626use pyrefly_types:: callable:: ParamList ;
2727use pyrefly_types:: callable:: Params ;
2828use pyrefly_types:: callable:: Required ;
29- use pyrefly_types:: display:: format_hover_code_snippet;
3029use pyrefly_types:: types:: BoundMethodType ;
3130use pyrefly_types:: types:: Forallable ;
3231use pyrefly_types:: types:: Type ;
@@ -219,39 +218,29 @@ impl HoverValue {
219218 let cleaned = doc. trim ( ) . replace ( '\n' , " \n " ) ;
220219 format ! ( "{prefix}**Parameter `{}`**\n {}" , name, cleaned)
221220 } ) ;
222- let mut kind_formatted = self . kind . map_or ( "" . to_owned ( ) , |kind| {
223- format ! ( "{} " , kind. display_for_hover( ) )
224- } ) ;
225- let name_formatted = self
226- . name
227- . as_ref ( )
228- . map_or ( "" . to_owned ( ) , |s| format ! ( "{s}: " ) ) ;
229- let symbol_def_formatted = if self . show_go_to_links {
230- HoverValue :: format_symbol_def_locations ( & self . type_ ) . unwrap_or ( "" . to_owned ( ) )
231- } else {
232- String :: new ( )
233- } ;
234- let type_display = self
235- . display
236- . clone ( )
237- . unwrap_or_else ( || self . type_ . as_hover_string ( ) ) ;
238- // Ensure callable hover bodies always contain a proper `def name(...)` so IDE syntax
239- // highlighting stays consistent, even when metadata is missing and we fall back to
240- // inferred identifiers.
241- let snippet = format_hover_code_snippet ( & self . type_ , self . name . as_deref ( ) , type_display) ;
242221 let kind_formatted = self . kind . map_or_else (
243222 || {
244- snippet
245- . default_kind_label
246- . map ( str:: to_owned)
247- . unwrap_or_default ( )
223+ if self . type_ . is_function_type ( ) {
224+ "(function) " . to_owned ( )
225+ } else {
226+ String :: new ( )
227+ }
248228 } ,
249229 |kind| format ! ( "{} " , kind. display_for_hover( ) ) ,
250230 ) ;
251231 let name_formatted = self
252232 . name
253233 . as_ref ( )
254234 . map_or ( "" . to_owned ( ) , |s| format ! ( "{s}: " ) ) ;
235+ let symbol_def_formatted = if self . show_go_to_links {
236+ HoverValue :: format_symbol_def_locations ( & self . type_ ) . unwrap_or ( "" . to_owned ( ) )
237+ } else {
238+ String :: new ( )
239+ } ;
240+ let type_display = self . display . clone ( ) . unwrap_or_else ( || {
241+ self . type_
242+ . as_hover_string_with_fallback_name ( self . name . as_deref ( ) )
243+ } ) ;
255244
256245 Hover {
257246 contents : HoverContents :: Markup ( MarkupContent {
@@ -450,15 +439,6 @@ pub fn get_hover(
450439 // Otherwise, fall through to the existing type hover logic
451440 let type_ = transaction. get_type_at ( handle, position) ?;
452441 let fallback_name_from_type = fallback_hover_name_from_type ( & type_) ;
453- let type_display = transaction. ad_hoc_solve ( handle, {
454- let mut cloned = type_. clone ( ) ;
455- move |solver| {
456- // If the type is a callable, rewrite the signature to expand TypedDict-based
457- // `**kwargs` entries, ensuring hover text shows the actual keyword names users can pass.
458- cloned. visit_toplevel_callable_mut ( |c| expand_callable_kwargs_for_hover ( & solver, c) ) ;
459- cloned. as_hover_string ( )
460- }
461- } ) ;
462442 let ( kind, name, docstring_range, module) = if let Some ( FindDefinitionItemWithDocstring {
463443 metadata,
464444 definition_range : definition_location,
@@ -499,6 +479,15 @@ pub fn get_hover(
499479
500480 let name = name. or_else ( || identifier_text_at ( transaction, handle, position) ) ;
501481
482+ let name_for_display = name. clone ( ) ;
483+ let type_display = transaction. ad_hoc_solve ( handle, {
484+ let mut cloned = type_. clone ( ) ;
485+ move |solver| {
486+ cloned. visit_toplevel_callable_mut ( |c| expand_callable_kwargs_for_hover ( & solver, c) ) ;
487+ cloned. as_hover_string_with_fallback_name ( name_for_display. as_deref ( ) )
488+ }
489+ } ) ;
490+
502491 let docstring = if let ( Some ( docstring) , Some ( module) ) = ( docstring_range, module) {
503492 Some ( Docstring ( docstring, module) )
504493 } else {
0 commit comments