[ty] add docstrings to completions based on type#20008
Conversation
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
|
Screen.Recording.2025-08-20.at.1.52.03.PM.mov |
| .map(|completion| Completion { | ||
| kind: completion.kind(&self.db).map(CompletionKind::from), | ||
| name: completion.name.into(), | ||
| name: completion.inner.name.into(), |
There was a problem hiding this comment.
It would be nice to also hook up documentation in the playground. You have to add a new documentation field to Completion, then propagate the field here
ruff/playground/ty/src/Editor/Editor.tsx
Line 321 in 8c0743d
There was a problem hiding this comment.
I think done? Never tested the playground.
|
|
||
| pub struct DetailedCompletion<'db> { | ||
| pub inner: Completion<'db>, | ||
| pub documentation: Option<Docstring>, |
There was a problem hiding this comment.
Should we make this a field on Completion instead that defaults to None: Given that completion is the only method constructing the completions
There was a problem hiding this comment.
Currently that doesn't work out because Docstring is defined in ty_ide and Completion is defined in ty_python_semantic. The crate boundaries have gotten quite wobbly 😅
* main: (29 commits) [ty] add docstrings to completions based on type (#20008) [`pyupgrade`] Avoid reporting `__future__` features as unnecessary when they are used (`UP010`) (#19769) [`flake8-use-pathlib`] Add fixes for `PTH102` and `PTH103` (#19514) [ty] correctly ignore field specifiers when not specified (#20002) `Option::unwrap` is now const (#20007) [ty] Re-arrange "list modules" implementation for Salsa caching [ty] Test "list modules" versus "resolve module" in every mdtest [ty] Wire up "list modules" API to make module completions work [ty] Tweak some completion tests [ty] Add "list modules" implementation [ty] Lightly expose `FileModule` and `NamespacePackage` fields [ty] Add some more helper routines to `ModulePath` [ty] Fix a bug when converting `ModulePath` to `ModuleName` [ty] Split out another constructor for `ModuleName` [ty] Add stub-file tests to existing module resolver [ty] Expose some routines in the module resolver [ty] Add more path helper functions [`flake8-annotations`] Remove unused import in example (`ANN401`) (#20000) [ty] distinguish base conda from child conda (#19990) [ty] Fix server hang (#19991) ...
This is a fairly simple but effective way to add docstrings to like 95% of completions from initial experimentation. Fixes astral-sh/ty#1036 Although ironically this approach *does not* work specifically for `print` and I haven't looked into why.
This is a fairly simple but effective way to add docstrings to like 95% of completions from initial experimentation.
Fixes astral-sh/ty#1036
Although ironically this approach does not work specifically for
printand I haven't looked into why.