]>
crepu.dev Git - config.git/blob - djavu-asus/elpy/rpc-venv/lib/python3.11/site-packages/jedi/api/keywords.py
2 from contextlib
import suppress
3 from typing
import Dict
, Optional
5 from jedi
.inference
.names
import AbstractArbitraryName
8 from pydoc_data
import topics
9 pydoc_topics
: Optional
[Dict
[str, str]] = topics
.topics
11 # Python 3.6.8 embeddable does not have pydoc_data.
15 class KeywordName(AbstractArbitraryName
):
19 return imitate_pydoc(self
.string_name
)
22 def imitate_pydoc(string
):
24 It's not possible to get the pydoc's without starting the annoying pager
27 if pydoc_topics
is None:
31 with
suppress(KeyError):
32 # try to access symbols
33 string
= h
.symbols
[string
]
34 string
, _
, related
= string
.partition(' ')
37 return h
.topics
.get(s
, h
.keywords
.get(s
))
39 while isinstance(string
, str):
40 string
= get_target(string
)
44 label
, related
= string
49 return pydoc_topics
[label
].strip() if pydoc_topics
else ''