Skip to content

Commit 4387672

Browse files
authored
Fix Python type error (#2487)
Latest pylance version is giving me the following error: ``` Cannot access attribute "__class__" for class "type[DataclassInstance]"   A property defined within a protocol class cannot be accessed as a class variable ``` Note that this solution came from a chat with chatgpt so I have no idea whether it's correct. Please review carefully. We really should have unit tests for this function I did run local talon tests and all green, as well as tried cheatsheet ## Checklist - [-] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [-] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [x] I have not broken the cheatsheet
1 parent e22456f commit 4387672

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cursorless-talon/src/command.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ def make_serializable(value: Any) -> Any:
9696
return [make_serializable(v) for v in value]
9797
if dataclasses.is_dataclass(value):
9898
items = {
99-
**{k: v for k, v in value.__class__.__dict__.items() if k[0] != "_"},
99+
**{
100+
k: v
101+
for k, v in vars(type(value)).items()
102+
if not k.startswith("_") and not isinstance(v, property)
103+
},
100104
**value.__dict__,
101105
}
102106
return {k: make_serializable(v) for k, v in items.items() if v is not None}

0 commit comments

Comments
 (0)