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

CorpusObject: add parameters to init #516

Merged
merged 3 commits into from
Jun 25, 2024
Merged

Conversation

Icemole
Copy link
Collaborator

@Icemole Icemole commented Jun 21, 2024

I find it much better to provide the parameters to an object via __init__ than to provide them by creating the object and explicitly setting the actual attribute. This helps for instance when I have to create a bunch of CorpusObjects in a list comprehension, which is similar to my use case.

If there was any explicit reason why these were not in the __init__ function please let me know.

@JackTemaki
Copy link
Contributor

Is there anything that speaks against making this a dataclass instead?

@JackTemaki JackTemaki requested a review from michelwi June 21, 2024 11:20
@Icemole
Copy link
Collaborator Author

Icemole commented Jun 21, 2024

Is there anything that speaks against making this a dataclass instead?

That's also a good idea :) the only thing I'm worried about is inheriting from a non-dataclass like tk.Object. Otherwise, nothing at all!

@JackTemaki
Copy link
Contributor

JackTemaki commented Jun 21, 2024

The inheritance can be removed, it plays no role at all as far as I can see. At least in i6_experiments there is not a single check for isinstance(tk.Object) and it does exactly nothing.

meta/system.py Outdated Show resolved Hide resolved
@Icemole
Copy link
Collaborator Author

Icemole commented Jun 21, 2024

The inheritance can be removed, it plays no role at all as far as I can see. At least in i6_experiments there is not a single check for isinstance(tk.Object) and it does exactly nothing.

Thanks for the feedback. I'll change it and leave it throughout the weekend, and if nobody complains we could merge this next week.

Also remove inheritance from tk.Object
Copy link
Contributor

@michelwi michelwi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was worried this might change hashes, but apparently it does not.

@Icemole Icemole merged commit e1feaa0 into main Jun 25, 2024
4 checks passed
@Icemole Icemole deleted the corpus-object-better-init branch June 25, 2024 15:14
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.

4 participants