mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-19 20:11:12 +08:00
The user context parser should ignore keywords if they are not standing alone.
This commit is contained in:
@@ -280,9 +280,7 @@ class Script(object):
|
|||||||
stmt = r.module.statements[-1]
|
stmt = r.module.statements[-1]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
raise NotFoundError()
|
raise NotFoundError()
|
||||||
if isinstance(stmt, pr.KeywordStatement):
|
if not isinstance(stmt, (pr.ExprStmt, pr.KeywordStatement)):
|
||||||
stmt = stmt.stmt
|
|
||||||
if not isinstance(stmt, pr.ExprStmt):
|
|
||||||
raise NotFoundError()
|
raise NotFoundError()
|
||||||
|
|
||||||
user_stmt = self._parser.user_stmt()
|
user_stmt = self._parser.user_stmt()
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
import keyword
|
||||||
|
|
||||||
from jedi import cache
|
from jedi import cache
|
||||||
from jedi import common
|
from jedi import common
|
||||||
@@ -104,6 +105,10 @@ class UserContext(object):
|
|||||||
elif tok_str in close_brackets:
|
elif tok_str in close_brackets:
|
||||||
level += 1
|
level += 1
|
||||||
elif tok_type in [tokenize.NAME, tokenize.STRING]:
|
elif tok_type in [tokenize.NAME, tokenize.STRING]:
|
||||||
|
if keyword.iskeyword(tok_str[::-1]) and string:
|
||||||
|
# If there's already something in the string, a keyword
|
||||||
|
# never adds any meaning to the current statement.
|
||||||
|
break
|
||||||
force_point = True
|
force_point = True
|
||||||
elif tok_type == tokenize.NUMBER:
|
elif tok_type == tokenize.NUMBER:
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user