mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-26 02:08:37 +08:00
@@ -39,6 +39,9 @@ class file():
|
|||||||
def readlines(self):
|
def readlines(self):
|
||||||
return ['']
|
return ['']
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
|
|
||||||
class xrange():
|
class xrange():
|
||||||
# Attention: this function doesn't exist in Py3k (there it is range).
|
# Attention: this function doesn't exist in Py3k (there it is range).
|
||||||
|
|||||||
@@ -7,3 +7,6 @@ class TextIOWrapper():
|
|||||||
|
|
||||||
def readlines(self):
|
def readlines(self):
|
||||||
return ['']
|
return ['']
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
return self
|
||||||
|
|||||||
@@ -221,7 +221,12 @@ def _name_to_types(evaluator, context, tree_name):
|
|||||||
elif typ == 'expr_stmt':
|
elif typ == 'expr_stmt':
|
||||||
types = _remove_statements(evaluator, context, node, tree_name)
|
types = _remove_statements(evaluator, context, node, tree_name)
|
||||||
elif typ == 'with_stmt':
|
elif typ == 'with_stmt':
|
||||||
types = context.eval_node(node.get_test_node_from_name(tree_name))
|
context_managers = context.eval_node(node.get_test_node_from_name(tree_name))
|
||||||
|
enter_methods = unite(
|
||||||
|
context_manager.py__getattribute__('__enter__')
|
||||||
|
for context_manager in context_managers
|
||||||
|
)
|
||||||
|
types = unite(method.execute_evaluated() for method in enter_methods)
|
||||||
elif typ in ('import_from', 'import_name'):
|
elif typ in ('import_from', 'import_name'):
|
||||||
types = imports.infer_import(context, tree_name)
|
types = imports.infer_import(context, tree_name)
|
||||||
elif typ in ('funcdef', 'classdef'):
|
elif typ in ('funcdef', 'classdef'):
|
||||||
|
|||||||
@@ -227,3 +227,12 @@ z = zipfile.ZipFile("foo")
|
|||||||
# It's too slow. So we don't run it at the moment.
|
# It's too slow. So we don't run it at the moment.
|
||||||
##? ['upper']
|
##? ['upper']
|
||||||
z.read('name').upper
|
z.read('name').upper
|
||||||
|
|
||||||
|
# -----------------
|
||||||
|
# contextlib
|
||||||
|
# -----------------
|
||||||
|
|
||||||
|
import contextlib
|
||||||
|
with contextlib.closing('asd') as string:
|
||||||
|
#? str()
|
||||||
|
string
|
||||||
|
|||||||
Reference in New Issue
Block a user