diff --git a/jedi/third_party/typeshed b/jedi/third_party/typeshed index d3864524..ae9d4f4b 160000 --- a/jedi/third_party/typeshed +++ b/jedi/third_party/typeshed @@ -1 +1 @@ -Subproject commit d38645247816f862cafeed21a8f4466d306aacf3 +Subproject commit ae9d4f4b21bb5e1239816c301da7b1ea904b44c3 diff --git a/test/completion/precedence.py b/test/completion/precedence.py index 5d8da12d..71c66e1f 100644 --- a/test/completion/precedence.py +++ b/test/completion/precedence.py @@ -54,7 +54,7 @@ a #? int() (3 ** 3) -#? int() str() +#? int() (3 ** 'a') #? int() (3 + 'a') diff --git a/test/static_analysis/with_.py b/test/static_analysis/with_.py deleted file mode 100644 index 29d1544f..00000000 --- a/test/static_analysis/with_.py +++ /dev/null @@ -1,2 +0,0 @@ -with open() as fin: - fin.read() diff --git a/test/test_api/test_api.py b/test/test_api/test_api.py index d2ebe62b..55feaf8b 100644 --- a/test/test_api/test_api.py +++ b/test/test_api/test_api.py @@ -173,7 +173,7 @@ def test_get_line_code(Script): return Script(source).complete(line=line)[0].get_line_code(**kwargs).replace('\r', '') # On builtin - assert get_line_code('abs') == 'def abs(__n: SupportsAbs[_T]) -> _T: ...\n' + assert get_line_code('abs') == 'def abs(__x: SupportsAbs[_T]) -> _T: ...\n' # On custom code first_line = 'def foo():\n' diff --git a/test/test_api/test_call_signatures.py b/test/test_api/test_call_signatures.py index 70631ebd..f7b5618a 100644 --- a/test/test_api/test_call_signatures.py +++ b/test/test_api/test_call_signatures.py @@ -39,12 +39,11 @@ class TestSignatures(TestCase): run = self._run_simple # simple - s1 = "sorted(a, bool(" - run(s1, 'sorted', 0, 7) - run(s1, 'sorted', 1, 9) - run(s1, 'sorted', 1, 10) - run(s1, 'sorted', None, 11) - run(s1, 'bool', 0, 15) + s1 = "tuple(a, bool(" + run(s1, 'tuple', 0, 6) + run(s1, 'tuple', None, 8) + run(s1, 'tuple', None, 9) + run(s1, 'bool', 0, 14) s2 = "abs(), " run(s2, 'abs', 0, 4) @@ -65,9 +64,9 @@ class TestSignatures(TestCase): run(s4, 'abs', 0, 10) run(s4, 'abs', None, 11) - s5 = "sorted(1,\nif 2:\n def a():" - run(s5, 'sorted', 0, 7) - run(s5, 'sorted', 1, 9) + s5 = "tuple(1,\nif 2:\n def a():" + run(s5, 'tuple', 0, 6) + run(s5, 'tuple', None, 8) s6 = "bool().__eq__(" run(s6, '__eq__', 0) @@ -89,8 +88,8 @@ class TestSignatures(TestCase): def test_for(self): # jedi-vim #11 - self._run_simple("for sorted(", 'sorted', 0) - self._run_simple("for s in sorted(", 'sorted', 0) + self._run_simple("for tuple(", 'tuple', 0) + self._run_simple("for s in tuple(", 'tuple', 0) def test_with(Script): @@ -272,7 +271,7 @@ def test_pow_params(Script): # See Github #1357. for sig in Script('pow(').get_signatures(): param_names = [p.name for p in sig.params] - assert param_names in (['x', 'y'], ['x', 'y', 'z']) + assert param_names in (['base', 'exp'], ['base', 'exp', 'mod']) def test_param_name(Script): diff --git a/test/test_api/test_classes.py b/test/test_api/test_classes.py index 4a6f7323..cb99548b 100644 --- a/test/test_api/test_classes.py +++ b/test/test_api/test_classes.py @@ -195,7 +195,7 @@ def test_hashlib_params(Script, environment): script = Script('from hashlib import sha256') c, = script.complete() sig, = c.get_signatures() - assert [p.name for p in sig.params] == ['arg'] + assert [p.name for p in sig.params] == ['string'] def test_signature_params(Script): @@ -619,7 +619,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(__n: 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', diff --git a/test/test_api/test_completion.py b/test/test_api/test_completion.py index 7805faba..b35bd059 100644 --- a/test/test_api/test_completion.py +++ b/test/test_api/test_completion.py @@ -150,19 +150,6 @@ def test_async(Script, environment): assert 'hey' in names -def test_method_doc_with_signature(Script): - code = 'f = open("")\nf.writelin' - c, = Script(code).complete() - assert c.name == 'writelines' - assert c.docstring() == 'writelines(lines: Iterable[AnyStr]) -> None' - - -def test_method_doc_with_signature2(Script): - code = 'f = open("")\nf.writelines' - d, = Script(code).goto() - assert d.docstring() == 'writelines(lines: Iterable[AnyStr]) -> None' - - def test_with_stmt_error_recovery(Script): assert Script('with open('') as foo: foo.\na').complete(line=1) diff --git a/test/test_api/test_documentation.py b/test/test_api/test_documentation.py index 104555cd..b86c68fc 100644 --- a/test/test_api/test_documentation.py +++ b/test/test_api/test_documentation.py @@ -95,7 +95,7 @@ def test_builtin_docstring(goto_or_help_or_infer): d, = goto_or_help_or_infer('open') doc = d.docstring() - assert doc.startswith('open(file: Union[') + assert doc.startswith('open(file: ') assert 'Open file' in doc diff --git a/test/test_inference/test_context.py b/test/test_inference/test_context.py index 2889e09d..84304703 100644 --- a/test/test_inference/test_context.py +++ b/test/test_inference/test_context.py @@ -15,4 +15,4 @@ def test_module__file__(Script, environment): def_, = Script('import antigravity; antigravity.__file__').infer() value = def_._name._value.get_safe_value() - assert value.endswith('.py') + assert value.endswith('.pyi') diff --git a/test/test_inference/test_gradual/test_typeshed.py b/test/test_inference/test_gradual/test_typeshed.py index ca48db11..ac3f1727 100644 --- a/test/test_inference/test_gradual/test_typeshed.py +++ b/test/test_inference/test_gradual/test_typeshed.py @@ -21,10 +21,10 @@ def test_get_typeshed_directories(): def transform(set_): return {x.replace('/', os.path.sep) for x in set_} - dirs = get_dirs(PythonVersionInfo(3, 6)) - assert dirs == transform({'stdlib/2and3', 'stdlib/3', - 'stdlib/3.6', 'third_party/2and3', - 'third_party/3', 'third_party/3.6'}) + dirs = get_dirs(PythonVersionInfo(3, 7)) + assert dirs == transform({'stdlib/2and3', 'stdlib/3', 'stdlib/3.7', + 'third_party/2and3', + 'third_party/3', 'third_party/3.7'}) def test_get_stub_files(): @@ -92,7 +92,7 @@ def test_sys_exc_info(Script): # It's an optional. assert def_.name == 'BaseException' assert def_.module_path == typeshed.TYPESHED_PATH.joinpath( - 'stdlib', '2and3', 'builtins.pyi' + 'stdlib', '3', 'builtins.pyi' ) assert def_.type == 'instance' assert none.name == 'NoneType' diff --git a/test/test_inference/test_signature.py b/test/test_inference/test_signature.py index a839fffd..a07bfa01 100644 --- a/test/test_inference/test_signature.py +++ b/test/test_inference/test_signature.py @@ -227,14 +227,22 @@ def test_nested_signatures(Script, environment, combination, expected): assert expected == computed -def test_pow_signature(Script): +def test_pow_signature(Script, environment): # See github #1357 sigs = Script('pow(').get_signatures() strings = {sig.to_string() for sig in sigs} - assert strings == {'pow(x: float, y: float, z: float, /) -> float', - 'pow(x: float, y: float, /) -> float', - 'pow(x: int, y: int, z: int, /) -> Any', - 'pow(x: int, y: int, /) -> Any'} + if environment.version_info < (3, 8): + assert strings == {'pow(base: _SupportsPow2[_E, _T_co], exp: _E, /) -> _T_co', + 'pow(base: _SupportsPow3[_E, _M, _T_co], exp: _E, mod: _M, /) -> _T_co', + 'pow(base: float, exp: float, mod: None=..., /) -> float', + 'pow(base: int, exp: int, mod: None=..., /) -> Any', + 'pow(base: int, exp: int, mod: int, /) -> int'} + else: + assert strings == {'pow(base: _SupportsPow2[_E, _T_co], exp: _E) -> _T_co', + 'pow(base: _SupportsPow3[_E, _M, _T_co], exp: _E, mod: _M) -> _T_co', + 'pow(base: float, exp: float, mod: None=...) -> float', + 'pow(base: int, exp: int, mod: None=...) -> Any', + 'pow(base: int, exp: int, mod: int) -> int'} @pytest.mark.parametrize(