Skip to content

feat: make all instance attributes on HasRid subclasse private #263

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

Closed
wants to merge 3 commits into from

Conversation

drake-nominal
Copy link
Contributor

@drake-nominal drake-nominal commented Mar 14, 2025

In a recent PR of mine, @stefanv had an excellent observation:

  • Users will find it confusing how you cannot update one of our HasRid subclasses as such:
    ds = client.get_dataset("... rid ...")
    ds.name = "my cool new name"
  • I have the additional observation that as our API changes, by preventing users from depending on our actual class attributes and instead exposing properties, we shield ourselves from having to make breaking changes as often. This can be seen with what happened with DataSource and the whole RID fiasco re: Channels.

Being the quick typer i am (aka regex) i have gone ahead and turned all API attributes into readonly properties.

Now, you might say, "but drake! our dataclasses are frozen, users should know they can't update these fields even in the first place!"

  • maybe they can't do ds.properties = {"very cool property name": "kinda lame property value"}, but they sure can still do ds.properties["python is cool"] = "but rust is wack".
  • See observation 2 above-- even if they couldn't modify mutable member variables, I claim we still don't want them accessing the member variables to begin with.
  • You'd be surprised how many people (that aren't python library developers) aren't intimately familiar with dataclasses to even consider this.

@drake-nominal drake-nominal requested review from stefanv and alkasm March 14, 2025 20:35
@drake-nominal
Copy link
Contributor Author

After discussion in slack, this was deemed not necessary

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

Successfully merging this pull request may close these issues.

1 participant