You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I have a component with an attribute using forward referencing,
e.g.
@quam_dataclass
class ComponentA(QuamComponent):
x: int
@quam_dataclass
class ComponentB(QuamComponent):
component_a = "ComponentA"
I get a ComponentA is not defined NameError when calling .save()
At the moment this is an issue for us, as we are using qubits and resonators which have resonator and qubit attributes respectively, and so to avoid circular imports we use forward referencing, which seems to work well, except that we can save our state.
The text was updated successfully, but these errors were encountered:
Forward referencing is indeed an issue, partly because determining the correct class from the string is problematic.
Can I suggest to first try adding if TYPE_CHECKING: and see if that resolves the issue. So for example:
This doesn't seem to work unfortunately, I get an error name 'Resonator' is not defined from the line resonator: Resonator when importing from qubit.py in your example.
If I have a component with an attribute using forward referencing,
e.g.
I get a ComponentA is not defined NameError when calling .save()
At the moment this is an issue for us, as we are using qubits and resonators which have resonator and qubit attributes respectively, and so to avoid circular imports we use forward referencing, which seems to work well, except that we can save our state.
The text was updated successfully, but these errors were encountered: