Change a few tests to match new typeshed

This commit is contained in:
Dave Halter
2026-04-29 09:30:49 +02:00
parent 04e5f5b3b8
commit fe0369436e
11 changed files with 29 additions and 25 deletions
+2 -2
View File
@@ -233,12 +233,12 @@ def a():
# str literals in comment """ upper
def completion_in_comment():
#? ['Exception']
#? ['Exception', 'ExceptionGroup']
# might fail because the comment is not a leaf: Exception
pass
some_word
#? ['Exception']
#? ['Exception', 'ExceptionGroup']
# Very simple comment completion: Exception
# Commment after it
+6 -6
View File
@@ -114,27 +114,27 @@ x(1, bar=2, ba)
x(1, ba, baz=3)
#? 14 ['baz=']
x(1, bar=2, baz=3)
#? 7 ['BaseException']
#? 7 ['BaseException', 'BaseExceptionGroup']
x(basee)
#? 22 ['bar=', 'baz=']
x(1, 2, 3, 4, 5, 6, bar=2)
#? 14 ['baz=']
y(1, bar=2, ba)
#? 7 ['bar=', 'BaseException', 'baz=']
#? 7 ['bar=', 'BaseException', 'BaseExceptionGroup', 'baz=']
y(1, ba, baz=3)
#? 14 ['baz=']
y(1, bar=2, baz=3)
#? 7 ['BaseException']
#? 7 ['BaseException', 'BaseExceptionGroup']
y(basee)
#? 22 ['bar=', 'BaseException', 'baz=']
#? 22 ['bar=', 'BaseException', 'BaseExceptionGroup', 'baz=']
y(1, 2, 3, 4, 5, 6, bar=2)
#? 11 ['bar=', 'bas=']
z(bam=1, bar=2, bas=3)
#? 8 ['BaseException', 'bas=']
#? 8 ['BaseException', 'BaseExceptionGroup', 'bas=']
z(1, bas=2)
#? 12 ['BaseException']
#? 12 ['BaseException', 'BaseExceptionGroup']
z(1, bas=bas)
#? 19 ['dict']
+1 -1
View File
@@ -34,7 +34,7 @@ def we_can_has_sequence(p: Sequence[int], q: Sequence[B], r: Sequence[int],
t[1]
#? ["append"]
u.a
#? float() list()
#? float()
u[1.0]
#? float()
u[1]
+1 -1
View File
@@ -360,7 +360,7 @@ X.attr_x.value
X.attr_y.name
#? float()
X.attr_y.value
#? str()
#?
X().name
#? float()
X().attr_x.attr_y.value
+3 -3
View File
@@ -192,7 +192,7 @@ def test_hashlib_params(Script):
script = Script('from hashlib import sha256')
c, = script.complete()
sig, = c.get_signatures()
assert [p.name for p in sig.params] == ['string']
assert [p.name for p in sig.params] == ['data', 'usedforsecurity', 'string']
def test_signature_params(Script):
@@ -465,7 +465,7 @@ def test_import(get_names):
nms = nms[2].goto()
assert nms
assert all(n.type == 'module' for n in nms)
assert 'posixpath' in {n.name for n in nms}
assert 'path' in {n.name for n in nms}
nms = get_names('import os.path', references=True)
n = nms[0].goto()[0]
@@ -616,7 +616,7 @@ def test_definition_goto_follow_imports(Script):
('n = next; n', 'Union[next(__i: Iterator[_T]) -> _T, '
'next(__i: Iterator[_T], default: _VT) -> Union[_T, _VT]]'),
('abs', 'abs(__x: SupportsAbs[_T]) -> _T'),
('abs', 'abs(x: SupportsAbs[_T], /) -> _T'),
('def foo(x, y): return x if xxxx else y\nfoo(str(), 1)\nfoo',
'foo(x: str, y: int) -> Union[int, str]'),
('def foo(x, y = None): return x if xxxx else y\nfoo(str(), 1)\nfoo',
+1 -1
View File
@@ -52,7 +52,7 @@ class TestFullNameWithGotoDefinitions(MixinTestFullName, TestCase):
self.check("""
import re
any_re = re.compile('.*')
any_re""", 'typing.Pattern')
any_re""", 're.Pattern')
def test_from_import(self):
self.check('from os import path', 'os.path')
+1 -1
View File
@@ -68,4 +68,4 @@ def test_param_kind_and_name(code, index, param_code, kind, Script):
def test_staticmethod(Script):
s, = Script('staticmethod(').get_signatures()
assert s.to_string() == 'staticmethod(f: Callable[..., Any])'
assert s.to_string() == 'staticmethod(f: Callable[_P, _R_co], /)'
+1 -1
View File
@@ -86,7 +86,7 @@ def test_time_docstring():
import time
comp, = jedi.Script('import time\ntime.sleep').complete()
assert comp.docstring(raw=True) == time.sleep.__doc__
expected = 'sleep(secs: float) -> None\n\n' + time.sleep.__doc__
expected = 'sleep(seconds: _SupportsFloatOrIndex, /) -> None\n\n' + time.sleep.__doc__
assert comp.docstring() == expected
+1 -1
View File
@@ -60,7 +60,7 @@ def test_instance_doc(Script):
'''Docstring of `TestClass`.'''
tc = TestClass()
tc""").infer()
assert defs[0].docstring() == 'Docstring of `TestClass`.'
assert defs[0].docstring() == 'TestClass()\n\nDocstring of `TestClass`.'
def test_multiple_docstrings(Script):
@@ -10,20 +10,20 @@ def test_sqlite3_conversion(Script):
script1 = Script('import sqlite3; sqlite3.Connection')
d, = script1.infer()
assert not d.module_path
assert d.module_path
assert d.full_name == 'sqlite3.Connection'
assert convert_names([d._name], only_stubs=True)
d, = script1.infer(only_stubs=True)
assert d.is_stub()
assert d.full_name == 'sqlite3.dbapi2.Connection'
assert d.full_name == 'sqlite3.Connection'
script2 = Script(path=d.module_path)
d, = script2.infer(line=d.line, column=d.column)
assert not d.is_stub()
assert d.is_stub()
assert d.full_name == 'sqlite3.Connection'
v, = d._name.infer()
assert v.is_compiled()
assert not v.is_compiled()
def test_conversion_of_stub_only(Script):
@@ -70,11 +70,11 @@ def test_stub_get_line_code(Script):
script = Script(code)
d, = script.goto(only_stubs=True)
# Replace \r for tests on Windows
assert d.get_line_code().replace('\r', '') == 'class ABC(metaclass=ABCMeta): ...\n'
assert d.get_line_code().replace('\r', '') == 'class ABC(metaclass=ABCMeta):\n'
del parser_cache[script._inference_state.latest_grammar._hashed][d.module_path]
d, = Script(path=d.module_path).goto(d.line, d.column, only_stubs=True)
assert d.is_stub()
assert d.get_line_code().replace('\r', '') == 'class ABC(metaclass=ABCMeta): ...\n'
assert d.get_line_code().replace('\r', '') == 'class ABC(metaclass=ABCMeta):\n'
def test_os_stat_result(Script):
+6 -2
View File
@@ -36,7 +36,7 @@ class TestSetupReadline(unittest.TestCase):
assert self.complete('list') == ['list']
assert self.complete('importerror') == ['ImportError']
s = "print(BaseE"
assert self.complete(s) == [s + 'xception']
assert self.complete(s) == [s + 'xception', s + 'xceptionGroup']
def test_nested(self):
assert self.complete('list.Insert') == ['list.insert']
@@ -69,7 +69,11 @@ class TestSetupReadline(unittest.TestCase):
def test_import(self):
s = 'from os.path import a'
assert set(self.complete(s)) == {s + 'ltsep', s + 'bspath'}
assert set(self.complete(s)) == {
s + 'ltsep',
s + 'bspath',
'from os.path import ALLOW_MISSING'
}
assert self.complete('import keyword') == ['import keyword']
import os