mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Make sure overload signatures work, see #1417
This commit is contained in:
2
test/examples/typing_overload/file.py
Normal file
2
test/examples/typing_overload/file.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
def with_overload(x, y: int) -> list:
|
||||||
|
pass
|
||||||
8
test/examples/typing_overload/file.pyi
Normal file
8
test/examples/typing_overload/file.pyi
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from typing import overload
|
||||||
|
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def with_overload(x: int, y: int) -> float: ...
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def with_overload(x: str, y: list) -> float: ...
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
from operator import ge, lt
|
from operator import ge, lt
|
||||||
import re
|
import re
|
||||||
|
import os
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from jedi.inference.gradual.conversion import _stub_to_python_value_set
|
from jedi.inference.gradual.conversion import _stub_to_python_value_set
|
||||||
|
from ..helpers import get_example_dir
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
@@ -289,3 +291,11 @@ def test_param_resolving_to_static(Script, stmt, expected, skip_pre_python35):
|
|||||||
|
|
||||||
sig, = Script(code).call_signatures()
|
sig, = Script(code).call_signatures()
|
||||||
assert sig.to_string() == expected
|
assert sig.to_string() == expected
|
||||||
|
|
||||||
|
|
||||||
|
def test_overload(Script):
|
||||||
|
dir_ = get_example_dir('typing_overload')
|
||||||
|
code = 'from file import with_overload; with_overload('
|
||||||
|
x1, x2 = Script(code, path=os.path.join(dir_, 'foo.py')).call_signatures()
|
||||||
|
assert x1.to_string() == 'with_overload(x: int, y: int) -> float'
|
||||||
|
assert x2.to_string() == 'with_overload(x: str, y: list) -> float'
|
||||||
|
|||||||
Reference in New Issue
Block a user