CadQuery / CadQuery/cadquery

Guidance needed on using de-serialization libraries with CADQuery editor

Open
#702 14 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
5.8k
Forks
541
Avg merge
3d 2h
Merged PRs (30d)
5

Description

I have a simple CADQuery script that makes use of several data classes, including this one:

```
@dataclass
class Point2:
'''Represents a 2D point.'''
x : float
y : float
```

I'd like to be able to de-serialize instances of these data classes from Python dictionaries (and later JSON) so I turned to _mashumaro_, which requires this mixin style:

```
@dataclass
class Point2(DataClassDictMixin):
'''Represents a 2D point.'''
x : float
y : float
```

De-serializing data class instances works as expected using this script from the command line, but when run in the CADQuery editor I can see an error in the Current Traceback window `KeyError: Temp` with the line pointing to the first mixed in data class. Execution stops at that point.

Okay, so I tried doing de-serialization with _dacite_, with no mixins required, but the editor gives the same error, this time pointing to the relevant `from_dict(...)` line. Again, the script works as expected when run from the command line.

Is there something special about running these scripts in the editor that I need to take into account?

I'm returning to Python (for CADQuery) after a very long break from using it, so I could well have misunderstood how to go about this.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.