This commit is contained in:
Eric Masseran
2025-03-17 19:48:42 +01:00
parent 7dcb944b05
commit bd1edfce78
2 changed files with 9 additions and 3 deletions

View File

@@ -593,8 +593,9 @@ def _random_choice(sequences):
def _dataclass(value, arguments, callback): def _dataclass(value, arguments, callback):
""" """
dataclass decorator can be called 2 times with different arguments. One to dataclass decorator can be called 2 times with different arguments. One to
customize it dataclass(eq=True) and another one with the class to customize it dataclass(eq=True) and another one with the class to transform.
transform.
It supports dataclass, dataclass_transform and attrs.
""" """
for c in _follow_param(value.inference_state, arguments, 0): for c in _follow_param(value.inference_state, arguments, 0):
if c.is_class(): if c.is_class():

View File

@@ -509,6 +509,10 @@ 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
): ):
has_typing_ext = bool(Script('import typing_extensions').infer())
if not has_typing_ext:
raise pytest.skip("typing_extensions needed in target environment to run this test")
code = dedent( code = dedent(
""" """
name: str name: str
@@ -596,7 +600,8 @@ def test_dataclass_transform_signature(
z = 5 z = 5
@define @define
class X(Y):'''), ['y']], class X(Y):'''), ['y']],
] ],
ids=["define", "frozen", "define_customized", "define_subclass", "define_both"]
) )
def test_attrs_signature(Script, skip_pre_python37, start, start_params): def test_attrs_signature(Script, skip_pre_python37, start, start_params):
has_attrs = bool(Script('import attrs').infer()) has_attrs = bool(Script('import attrs').infer())