mirror of
https://github.com/NVIDIA/cutlass.git
synced 2026-05-12 01:10:08 +00:00
Add support for empty dataclass arguments (#3152)
A dataclass with no fields exposed a bug in `extract_dataclass_members`: ``` @dataclass class Dummy: pass ``` The type/return path was inconsistent. This PR fixes the function to support empty dataclasses, which are useful in unions.
This commit is contained in:
@@ -192,7 +192,7 @@ class Leaf:
|
||||
# =============================================================================
|
||||
|
||||
|
||||
def extract_dataclass_members(x: Any) -> tuple[list[str], list[Any]]:
|
||||
def extract_dataclass_members(x: Any) -> tuple[list[str], list[Any], list[Any]]:
|
||||
"""
|
||||
Extract non-method, non-function attributes from a dataclass instance.
|
||||
|
||||
@@ -200,7 +200,7 @@ def extract_dataclass_members(x: Any) -> tuple[list[str], list[Any]]:
|
||||
x: A dataclass instance
|
||||
|
||||
Returns:
|
||||
tuple: (field_names, field_values) lists
|
||||
tuple: (field_names, field_values, constexpr_fields) lists
|
||||
"""
|
||||
fields = [field.name for field in dataclasses.fields(x)]
|
||||
|
||||
@@ -213,7 +213,7 @@ def extract_dataclass_members(x: Any) -> tuple[list[str], list[Any]]:
|
||||
)
|
||||
|
||||
if not fields:
|
||||
return [], []
|
||||
return [], [], []
|
||||
|
||||
# record constexpr fields
|
||||
members = []
|
||||
|
||||
Reference in New Issue
Block a user