mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
Dataclass transform typing extension without Final support
This commit is contained in:
@@ -563,18 +563,26 @@ ids = [
|
|||||||
'start, start_params, include_params', dataclass_transform_cases, ids=ids
|
'start, start_params, include_params', dataclass_transform_cases, ids=ids
|
||||||
)
|
)
|
||||||
def test_extensions_dataclass_transform_signature(
|
def test_extensions_dataclass_transform_signature(
|
||||||
Script, skip_pre_python37, start, start_params, include_params
|
Script, skip_pre_python37, start, start_params, include_params, environment
|
||||||
):
|
):
|
||||||
has_typing_ext = bool(Script('import typing_extensions').infer())
|
has_typing_ext = bool(Script('import typing_extensions').infer())
|
||||||
if not has_typing_ext:
|
if not has_typing_ext:
|
||||||
raise pytest.skip("typing_extensions needed in target environment to run this test")
|
raise pytest.skip("typing_extensions needed in target environment to run this test")
|
||||||
|
|
||||||
|
if environment.version_info < (3, 8):
|
||||||
|
# Final is not yet supported
|
||||||
|
price_type = "float"
|
||||||
|
price_type_infer = "float"
|
||||||
|
else:
|
||||||
|
price_type = "Final[float]"
|
||||||
|
price_type_infer = "object"
|
||||||
|
|
||||||
code = dedent(
|
code = dedent(
|
||||||
"""
|
f"""
|
||||||
name: str
|
name: str
|
||||||
foo = 3
|
foo = 3
|
||||||
blob: ClassVar[str]
|
blob: ClassVar[str]
|
||||||
price: Final[float]
|
price: {price_type}
|
||||||
quantity: int = 0.0
|
quantity: int = 0.0
|
||||||
|
|
||||||
X("""
|
X("""
|
||||||
@@ -599,7 +607,7 @@ def test_extensions_dataclass_transform_signature(
|
|||||||
quantity, = sig.params[-1].infer()
|
quantity, = sig.params[-1].infer()
|
||||||
assert quantity.name == 'int'
|
assert quantity.name == 'int'
|
||||||
price, = sig.params[-2].infer()
|
price, = sig.params[-2].infer()
|
||||||
assert price.name == 'object'
|
assert price.name == price_type_infer
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
|||||||
Reference in New Issue
Block a user