mirror of
https://github.com/davidhalter/jedi.git
synced 2026-10-15 18:22:35 +08:00
Avoid a crash, fixes #1990
This commit is contained in:
1 parent
ea1b96ff10
commit
dd7d4a92f4
2 files changed
+19
-3
No files matched your search
@@ -873,3 +873,20 @@ def test_whitespace_after_dot_completion(Script):
|
||||
# From #1954
|
||||
completions = jedi.Interpreter("object. \n", []).complete(1, 8)
|
||||
assert "mro" in [c.name for c in completions]
|
||||
|
||||
|
||||
def test_interpreter_with_literals_no_crash():
|
||||
# From #1990
|
||||
class A:
|
||||
@property
|
||||
def value(self) -> typing.Literal["a"]:
|
||||
return "a"
|
||||
|
||||
a = A()
|
||||
|
||||
interpreter = jedi.Interpreter("a.", [{"a": a}])
|
||||
value = next(filter(lambda c: c.name == "value", interpreter.complete()))
|
||||
assert value.name == "value"
|
||||
|
||||
interpreter = jedi.Interpreter("a.value.", [{"a": a}])
|
||||
assert "upper" in [c.name for c in interpreter.complete()]
|
||||
Reference in new issue
Block a user