Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make .parent a read-only property #615

Open
coretl opened this issue Oct 17, 2024 · 1 comment
Open

Make .parent a read-only property #615

coretl opened this issue Oct 17, 2024 · 1 comment

Comments

@coretl
Copy link
Collaborator

coretl commented Oct 17, 2024

At the moment this is a read/write attribute on the class set from the outside. It is only ever set by its parent, so could be passed in the creation of children like in ophyd, but don't want to make the epics_signal_rw case messier:

self.x = epics_signal_rw(int, prefix+"x", parent=self)

There's not a nice way round setting the parent apart from doing child._parent = self # noqa: SLF001 in the __setattr__ method.

We should discuss

Acceptance Criteria

  • .parent is a read-only public property with a suitable mechanism for setting
@evalott100
Copy link
Contributor

We should also use name mangling so parent isn't overwritten by subclasses

#594 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants