-
-
Notifications
You must be signed in to change notification settings - Fork 524
Open
Labels
Description
In Python 3.14, some implementation details of typing have been changed, for example: python/cpython#105499
This is causing failures of some of the tests:
=================================== FAILURES ===================================
________________ test_string_annotation[annotations8-result8-] _________________
annotations = {'return': 'typing.Union[str, int]'}, result = ['int', 'str']
code = ''
@pytest.mark.parametrize(
'annotations, result, code', [
({}, [], ''),
(None, [], ''),
({'asdf': 'str'}, [], ''),
({'return': 'str'}, ['str'], ''),
({'return': 'None'}, ['NoneType'], ''),
({'return': 'str().upper'}, [], ''),
({'return': 'foo()'}, [], ''),
({'return': 'bar()'}, ['float'], ''),
# typing is available via globals.
({'return': 'typing.Union[str, int]'}, ['int', 'str'], ''),
({'return': 'typing.Union["str", int]'},
['int', 'str'] if sys.version_info >= (3, 9) else ['int'], ''),
({'return': 'typing.Union["str", 1]'},
['str'] if sys.version_info >= (3, 11) else [], ''),
({'return': 'typing.Optional[str]'}, ['NoneType', 'str'], ''),
({'return': 'typing.Optional[str, int]'}, [], ''), # Takes only one arg
({'return': 'typing.Any'},
['_AnyMeta'] if sys.version_info >= (3, 11) else [], ''),
({'return': 'typing.Tuple[int, str]'},
['Tuple' if sys.version_info[:2] == (3, 6) else 'tuple'], ''),
({'return': 'typing.Tuple[int, str]'}, ['int'], 'x()[0]'),
({'return': 'typing.Tuple[int, str]'}, ['str'], 'x()[1]'),
({'return': 'typing.Tuple[int, str]'}, [], 'x()[2]'),
({'return': 'typing.List'}, ['list'], 'list'),
({'return': 'typing.List[int]'}, ['list'], 'list'),
({'return': 'typing.List[int]'}, ['int'], 'x()[0]'),
({'return': 'typing.List[int, str]'}, [], 'x()[0]'),
({'return': 'typing.Iterator[int]'}, [], 'x()[0]'),
({'return': 'typing.Iterator[int]'}, ['int'], 'next(x())'),
({'return': 'typing.Iterable[float]'}, ['float'], 'list(x())[0]'),
({'return': 'decimal.Decimal'}, [], ''),
({'return': 'lalalalallalaa'}, [], ''),
({'return': 'lalalalallalaa.lala'}, [], ''),
]
)
def test_string_annotation(annotations, result, code):
x = lambda foo: 1 # noqa: E731
x.__annotations__ = annotations
defs = jedi.Interpreter(code or 'x()', [locals()]).infer()
> assert [d.name for d in defs] == result
E AssertionError: assert [] == ['int', 'str']
E
E Right contains 2 more items, first extra item: 'int'
E Use -v to get more diff
test/test_api/test_interpreter.py:697: AssertionError
________________ test_string_annotation[annotations9-result9-] _________________
annotations = {'return': 'typing.Union["str", int]'}, result = ['int', 'str']
code = ''
@pytest.mark.parametrize(
'annotations, result, code', [
({}, [], ''),
(None, [], ''),
({'asdf': 'str'}, [], ''),
({'return': 'str'}, ['str'], ''),
({'return': 'None'}, ['NoneType'], ''),
({'return': 'str().upper'}, [], ''),
({'return': 'foo()'}, [], ''),
({'return': 'bar()'}, ['float'], ''),
# typing is available via globals.
({'return': 'typing.Union[str, int]'}, ['int', 'str'], ''),
({'return': 'typing.Union["str", int]'},
['int', 'str'] if sys.version_info >= (3, 9) else ['int'], ''),
({'return': 'typing.Union["str", 1]'},
['str'] if sys.version_info >= (3, 11) else [], ''),
({'return': 'typing.Optional[str]'}, ['NoneType', 'str'], ''),
({'return': 'typing.Optional[str, int]'}, [], ''), # Takes only one arg
({'return': 'typing.Any'},
['_AnyMeta'] if sys.version_info >= (3, 11) else [], ''),
({'return': 'typing.Tuple[int, str]'},
['Tuple' if sys.version_info[:2] == (3, 6) else 'tuple'], ''),
({'return': 'typing.Tuple[int, str]'}, ['int'], 'x()[0]'),
({'return': 'typing.Tuple[int, str]'}, ['str'], 'x()[1]'),
({'return': 'typing.Tuple[int, str]'}, [], 'x()[2]'),
({'return': 'typing.List'}, ['list'], 'list'),
({'return': 'typing.List[int]'}, ['list'], 'list'),
({'return': 'typing.List[int]'}, ['int'], 'x()[0]'),
({'return': 'typing.List[int, str]'}, [], 'x()[0]'),
({'return': 'typing.Iterator[int]'}, [], 'x()[0]'),
({'return': 'typing.Iterator[int]'}, ['int'], 'next(x())'),
({'return': 'typing.Iterable[float]'}, ['float'], 'list(x())[0]'),
({'return': 'decimal.Decimal'}, [], ''),
({'return': 'lalalalallalaa'}, [], ''),
({'return': 'lalalalallalaa.lala'}, [], ''),
]
)
def test_string_annotation(annotations, result, code):
x = lambda foo: 1 # noqa: E731
x.__annotations__ = annotations
defs = jedi.Interpreter(code or 'x()', [locals()]).infer()
> assert [d.name for d in defs] == result
E AssertionError: assert [] == ['int', 'str']
E
E Right contains 2 more items, first extra item: 'int'
E Use -v to get more diff
test/test_api/test_interpreter.py:697: AssertionError
_______________ test_string_annotation[annotations10-result10-] ________________
annotations = {'return': 'typing.Union["str", 1]'}, result = ['str'], code = ''
@pytest.mark.parametrize(
'annotations, result, code', [
({}, [], ''),
(None, [], ''),
({'asdf': 'str'}, [], ''),
({'return': 'str'}, ['str'], ''),
({'return': 'None'}, ['NoneType'], ''),
({'return': 'str().upper'}, [], ''),
({'return': 'foo()'}, [], ''),
({'return': 'bar()'}, ['float'], ''),
# typing is available via globals.
({'return': 'typing.Union[str, int]'}, ['int', 'str'], ''),
({'return': 'typing.Union["str", int]'},
['int', 'str'] if sys.version_info >= (3, 9) else ['int'], ''),
({'return': 'typing.Union["str", 1]'},
['str'] if sys.version_info >= (3, 11) else [], ''),
({'return': 'typing.Optional[str]'}, ['NoneType', 'str'], ''),
({'return': 'typing.Optional[str, int]'}, [], ''), # Takes only one arg
({'return': 'typing.Any'},
['_AnyMeta'] if sys.version_info >= (3, 11) else [], ''),
({'return': 'typing.Tuple[int, str]'},
['Tuple' if sys.version_info[:2] == (3, 6) else 'tuple'], ''),
({'return': 'typing.Tuple[int, str]'}, ['int'], 'x()[0]'),
({'return': 'typing.Tuple[int, str]'}, ['str'], 'x()[1]'),
({'return': 'typing.Tuple[int, str]'}, [], 'x()[2]'),
({'return': 'typing.List'}, ['list'], 'list'),
({'return': 'typing.List[int]'}, ['list'], 'list'),
({'return': 'typing.List[int]'}, ['int'], 'x()[0]'),
({'return': 'typing.List[int, str]'}, [], 'x()[0]'),
({'return': 'typing.Iterator[int]'}, [], 'x()[0]'),
({'return': 'typing.Iterator[int]'}, ['int'], 'next(x())'),
({'return': 'typing.Iterable[float]'}, ['float'], 'list(x())[0]'),
({'return': 'decimal.Decimal'}, [], ''),
({'return': 'lalalalallalaa'}, [], ''),
({'return': 'lalalalallalaa.lala'}, [], ''),
]
)
def test_string_annotation(annotations, result, code):
x = lambda foo: 1 # noqa: E731
x.__annotations__ = annotations
defs = jedi.Interpreter(code or 'x()', [locals()]).infer()
> assert [d.name for d in defs] == result
E AssertionError: assert [] == ['str']
E
E Right contains one more item: 'str'
E Use -v to get more diff
test/test_api/test_interpreter.py:697: AssertionError
_______________ test_string_annotation[annotations11-result11-] ________________
annotations = {'return': 'typing.Optional[str]'}, result = ['NoneType', 'str']
code = ''
@pytest.mark.parametrize(
'annotations, result, code', [
({}, [], ''),
(None, [], ''),
({'asdf': 'str'}, [], ''),
({'return': 'str'}, ['str'], ''),
({'return': 'None'}, ['NoneType'], ''),
({'return': 'str().upper'}, [], ''),
({'return': 'foo()'}, [], ''),
({'return': 'bar()'}, ['float'], ''),
# typing is available via globals.
({'return': 'typing.Union[str, int]'}, ['int', 'str'], ''),
({'return': 'typing.Union["str", int]'},
['int', 'str'] if sys.version_info >= (3, 9) else ['int'], ''),
({'return': 'typing.Union["str", 1]'},
['str'] if sys.version_info >= (3, 11) else [], ''),
({'return': 'typing.Optional[str]'}, ['NoneType', 'str'], ''),
({'return': 'typing.Optional[str, int]'}, [], ''), # Takes only one arg
({'return': 'typing.Any'},
['_AnyMeta'] if sys.version_info >= (3, 11) else [], ''),
({'return': 'typing.Tuple[int, str]'},
['Tuple' if sys.version_info[:2] == (3, 6) else 'tuple'], ''),
({'return': 'typing.Tuple[int, str]'}, ['int'], 'x()[0]'),
({'return': 'typing.Tuple[int, str]'}, ['str'], 'x()[1]'),
({'return': 'typing.Tuple[int, str]'}, [], 'x()[2]'),
({'return': 'typing.List'}, ['list'], 'list'),
({'return': 'typing.List[int]'}, ['list'], 'list'),
({'return': 'typing.List[int]'}, ['int'], 'x()[0]'),
({'return': 'typing.List[int, str]'}, [], 'x()[0]'),
({'return': 'typing.Iterator[int]'}, [], 'x()[0]'),
({'return': 'typing.Iterator[int]'}, ['int'], 'next(x())'),
({'return': 'typing.Iterable[float]'}, ['float'], 'list(x())[0]'),
({'return': 'decimal.Decimal'}, [], ''),
({'return': 'lalalalallalaa'}, [], ''),
({'return': 'lalalalallalaa.lala'}, [], ''),
]
)
def test_string_annotation(annotations, result, code):
x = lambda foo: 1 # noqa: E731
x.__annotations__ = annotations
defs = jedi.Interpreter(code or 'x()', [locals()]).infer()
> assert [d.name for d in defs] == result
E AssertionError: assert [] == ['NoneType', 'str']
E
E Right contains 2 more items, first extra item: 'NoneType'
E Use -v to get more diff
test/test_api/test_interpreter.py:697: AssertionError
=========================== short test summary info ============================
FAILED test/test_api/test_interpreter.py::test_string_annotation[annotations8-result8-]
FAILED test/test_api/test_interpreter.py::test_string_annotation[annotations9-result9-]
FAILED test/test_api/test_interpreter.py::test_string_annotation[annotations10-result10-]
FAILED test/test_api/test_interpreter.py::test_string_annotation[annotations11-result11-]
==== 4 failed, 3770 passed, 22 skipped, 96 deselected, 1 xfailed in 46.74s =====
Reactions are currently unavailable