mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 23:34:45 +08:00
Specially crafted docstrings sometimes lead to errors, fixes #1103
This commit is contained in:
@@ -214,6 +214,9 @@ def _evaluate_for_statement_string(module_context, string):
|
|||||||
except (AttributeError, IndexError):
|
except (AttributeError, IndexError):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
if stmt.type not in ('name', 'atom', 'atom_expr'):
|
||||||
|
return []
|
||||||
|
|
||||||
from jedi.evaluate.context import FunctionContext
|
from jedi.evaluate.context import FunctionContext
|
||||||
function_context = FunctionContext(
|
function_context = FunctionContext(
|
||||||
module_context.evaluator,
|
module_context.evaluator,
|
||||||
|
|||||||
@@ -74,8 +74,10 @@ def eval_node(context, element):
|
|||||||
# For False/True/None
|
# For False/True/None
|
||||||
if element.value in ('False', 'True', 'None'):
|
if element.value in ('False', 'True', 'None'):
|
||||||
return ContextSet(compiled.builtin_from_name(evaluator, element.value))
|
return ContextSet(compiled.builtin_from_name(evaluator, element.value))
|
||||||
# else: print e.g. could be evaluated like this in Python 2.7
|
if element.value == 'print':
|
||||||
return NO_CONTEXTS
|
# print e.g. could be evaluated like this in Python 2.7
|
||||||
|
return NO_CONTEXTS
|
||||||
|
assert False, 'Cannot evaluate the keyword %s' % element
|
||||||
elif typ == 'lambdef':
|
elif typ == 'lambdef':
|
||||||
return ContextSet(FunctionContext(evaluator, context, element))
|
return ContextSet(FunctionContext(evaluator, context, element))
|
||||||
elif typ == 'expr_stmt':
|
elif typ == 'expr_stmt':
|
||||||
|
|||||||
@@ -30,13 +30,17 @@ def sphinxy(a, b, c, d, x):
|
|||||||
sphinxy()
|
sphinxy()
|
||||||
|
|
||||||
# wrong declarations
|
# wrong declarations
|
||||||
def sphinxy2(a, b, x):
|
def sphinxy2(a, b, x, y, z):
|
||||||
"""
|
"""
|
||||||
:param a: Forgot type declaration
|
:param a: Forgot type declaration
|
||||||
:type a:
|
:type a:
|
||||||
:param b: Just something
|
:param b: Just something
|
||||||
:type b: ``
|
:type b: ``
|
||||||
:param x: Just something without type
|
:param x: Just something without type
|
||||||
|
:param y: A function
|
||||||
|
:type y: def l(): pass
|
||||||
|
:param z: A keyword
|
||||||
|
:type z: return
|
||||||
:rtype:
|
:rtype:
|
||||||
"""
|
"""
|
||||||
#?
|
#?
|
||||||
@@ -45,6 +49,10 @@ def sphinxy2(a, b, x):
|
|||||||
b
|
b
|
||||||
#?
|
#?
|
||||||
x
|
x
|
||||||
|
#?
|
||||||
|
y
|
||||||
|
#?
|
||||||
|
z
|
||||||
|
|
||||||
#?
|
#?
|
||||||
sphinxy2()
|
sphinxy2()
|
||||||
|
|||||||
Reference in New Issue
Block a user