1
0
forked from VimPlug/jedi

Move get_special_object

This commit is contained in:
Dave Halter
2017-12-05 00:32:39 +01:00
parent 542644ad19
commit 79071790da
2 changed files with 26 additions and 19 deletions
+22
View File
@@ -55,6 +55,13 @@ ALLOWED_DESCRIPTOR_ACCESS = (
classmethod,
)
def _a_generator(foo):
"""Used to have an object to return for generators."""
yield 42
yield foo
_sentinel = object()
# Maps Python syntax to the operator module.
@@ -378,3 +385,18 @@ def _is_class_instance(obj):
return False
else:
return cls != type and not issubclass(cls, NOT_CLASS_TYPES)
_SPECIAL_OBJECTS = {
'FUNCTION_CLASS': types.FunctionType,
'METHOD_CLASS': type(DirectObjectAccess.py__bool__),
'MODULE_CLASS': types.ModuleType,
'GENERATOR_OBJECT': _a_generator(1.0),
'BUILTINS': builtins,
}
def get_special_object(evaluator, identifier):
obj = _SPECIAL_OBJECTS[identifier]
return create_access_path(evaluator, obj)