Fix docstrings for param completions, fixes #2063, fixes #2109

This commit is contained in:
Dave Halter
2026-09-27 11:41:13 +02:00
parent 112d255414
commit ed47f89162
2 changed files with 19 additions and 1 deletions
+1 -1
View File
@@ -551,7 +551,7 @@ class BaseName:
return ''.join(lines[start_index:index + after + 1])
def _get_signatures(self, for_docstring=False):
if self._name.api_type == 'property':
if self._name.api_type in ('property', 'param'):
return []
if for_docstring and self._name.api_type == 'statement' and not self.is_stub():
# For docstrings we don't resolve signatures if they are simple
+18
View File
@@ -462,3 +462,21 @@ def test_module_completions(Script, module):
def test_whitespace_at_end_after_dot(Script):
assert 'strip' in [c.name for c in Script('str. ').complete()]
def test_param_docstring_in_completion(Script):
# From Github #2063
code = '''\
from typing import Optional
def func(arg: Optional[int]):
pass
func(arg'''
script = Script(code=code)
completions = script.complete(
line=len(code.splitlines()),
column=len(code.splitlines()[-1])
)
c, = completions
assert c.docstring() == ''