forked from VimPlug/jedi
Use split_lines and python_bytes_to_unicode directly.
This commit is contained in:
@@ -15,7 +15,7 @@ import sys
|
||||
|
||||
import parso
|
||||
from parso.python import tree
|
||||
from parso.utils import python_bytes_to_unicode, split_lines
|
||||
from parso import python_bytes_to_unicode, split_lines
|
||||
|
||||
from jedi.parser_utils import get_executable_nodes, get_statement_of_position
|
||||
from jedi import debug
|
||||
|
||||
@@ -7,7 +7,7 @@ from textwrap import dedent
|
||||
|
||||
from parso.python.parser import Parser
|
||||
from parso.python import tree
|
||||
from parso.utils import split_lines
|
||||
from parso import split_lines
|
||||
|
||||
from jedi._compatibility import u
|
||||
from jedi.evaluate.helpers import evaluate_call_of_leaf
|
||||
|
||||
@@ -8,6 +8,11 @@ from jedi.evaluate.compiled import mixed
|
||||
from jedi.evaluate.context import Context
|
||||
|
||||
|
||||
class NamespaceObject(object):
|
||||
def __init__(self, dct):
|
||||
self.__dict__ = dct
|
||||
|
||||
|
||||
class MixedModuleContext(Context):
|
||||
resets_positions = True
|
||||
type = 'mixed_module'
|
||||
@@ -16,7 +21,7 @@ class MixedModuleContext(Context):
|
||||
self.evaluator = evaluator
|
||||
self._namespaces = namespaces
|
||||
|
||||
self._namespace_objects = [type('jedi_namespace', (), n) for n in namespaces]
|
||||
self._namespace_objects = [NamespaceObject(n) for n in namespaces]
|
||||
self._module_context = ModuleContext(evaluator, tree_module, path=path)
|
||||
self.tree_node = tree_module
|
||||
|
||||
|
||||
@@ -76,12 +76,16 @@ class KeywordName(AbstractNameDefinition):
|
||||
api_type = 'keyword'
|
||||
|
||||
def __init__(self, evaluator, name):
|
||||
self.evaluator = evaluator
|
||||
self.string_name = name
|
||||
self.parent_context = evaluator.BUILTINS
|
||||
|
||||
def eval(self):
|
||||
return set()
|
||||
|
||||
def infer(self):
|
||||
return [Keyword(self.evaluator, self.string_name, (0, 0))]
|
||||
|
||||
|
||||
class Keyword(object):
|
||||
api_type = 'keyword'
|
||||
@@ -100,9 +104,8 @@ class Keyword(object):
|
||||
""" For a `parsing.Name` like comparision """
|
||||
return [self.name]
|
||||
|
||||
@property
|
||||
def docstr(self):
|
||||
return imitate_pydoc(self.name)
|
||||
def py__doc__(self, include_call_signature=False):
|
||||
return imitate_pydoc(self.name.string_name)
|
||||
|
||||
def __repr__(self):
|
||||
return '<%s: %s>' % (type(self).__name__, self.name)
|
||||
@@ -136,6 +139,6 @@ def imitate_pydoc(string):
|
||||
return ''
|
||||
|
||||
try:
|
||||
return pydoc_topics.topics[label] if pydoc_topics else ''
|
||||
return pydoc_topics.topics[label].strip() if pydoc_topics else ''
|
||||
except KeyError:
|
||||
return ''
|
||||
|
||||
Reference in New Issue
Block a user