diff --git a/crates/ty_python_semantic/resources/mdtest/snapshots/attributes.md_-_Attributes_-_Diagnostic_for_funct…_(340818ba77052e65).snap b/crates/ty_python_semantic/resources/mdtest/snapshots/attributes.md_-_Attributes_-_Diagnostic_for_funct…_(340818ba77052e65).snap index 01269b5a9e..6ff1668d26 100644 --- a/crates/ty_python_semantic/resources/mdtest/snapshots/attributes.md_-_Attributes_-_Diagnostic_for_funct…_(340818ba77052e65).snap +++ b/crates/ty_python_semantic/resources/mdtest/snapshots/attributes.md_-_Attributes_-_Diagnostic_for_funct…_(340818ba77052e65).snap @@ -2,7 +2,6 @@ source: crates/ty_test/src/lib.rs expression: snapshot --- - --- mdtest name: attributes.md - Attributes - Diagnostic for function attribute accessed on `Callable` type mdtest path: crates/ty_python_semantic/resources/mdtest/attributes.md @@ -32,6 +31,7 @@ error[unresolved-attribute]: Object of type `(...) -> Unknown` has no attribute 5 | x.__annotate__ # error: [unresolved-attribute] | help: Function objects have a `__name__` attribute, but not all callable objects are functions +help: See this FAQ for more information: info: rule `unresolved-attribute` is enabled by default ``` @@ -46,6 +46,7 @@ error[unresolved-attribute]: Object of type `(...) -> Unknown` has no attribute | ^^^^^^^^^^^^^^ | help: Function objects have an `__annotate__` attribute, but not all callable objects are functions +help: See this FAQ for more information: info: rule `unresolved-attribute` is enabled by default ``` diff --git a/crates/ty_python_semantic/src/types/infer/builder.rs b/crates/ty_python_semantic/src/types/infer/builder.rs index be501ec00c..5a1d41eeb3 100644 --- a/crates/ty_python_semantic/src/types/infer/builder.rs +++ b/crates/ty_python_semantic/src/types/infer/builder.rs @@ -10115,6 +10115,16 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { "" }, )); + + // without the <> around the URL, if you double click on the URL in the terminal it tries to load + // https://docs.astral.sh/ty/reference/typing-faq/#why-does-ty-say-callable-has-no-attribute-__name + // (without the __ suffix at the end of the URL). That doesn't exist, so the page loaded in the + // browser opens at the top of the FAQs page instead of taking you directly to the relevant FAQ. + diagnostic.help( + "See this FAQ for more information: \ + ", + ); } else { hint_if_stdlib_attribute_exists_on_other_versions( db,