Skip to content

Init calls subclass method pattern #12220

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
timhoffm opened this issue Sep 22, 2018 · 5 comments
Closed

Init calls subclass method pattern #12220

timhoffm opened this issue Sep 22, 2018 · 5 comments
Labels
status: inactive Marked by the “Stale” Github Action

Comments

@timhoffm
Copy link
Member

We have a lot of places with the init-calls-subclass pattern.

This cause problems if the subclass method relies on subclass attributes that have not yet been set up.

I actually ran into the issue in #12215.

  • Has anyone encountered this before?
  • Do we have a strategy how to avoid this issue?
@anntzer
Copy link
Contributor

anntzer commented Sep 22, 2018

A lot of these are explicitly here to provide customization points of the initialization to subclasses... I wouldn't overly worry about them unless they are actually problematic (which can definitely happen).

@tacaswell
Copy link
Member

I agree with @anntzer, many of the cases where we have this are using setters (you have the same problem with properties) that cause non-trivial internal state change. We both want to override those things in sub-classes and to set up defaults in __init__ (and to not have the state setting logic in 2x places) so I think we just have to absorb this complexity.

The advise to use composition is well meaning, but I don't think practical for us....

@timhoffm
Copy link
Member Author

For setters/properties, it would be work to define the subclass attributes before calling the super init.

Would that be a reasonable pattern?

@github-actions
Copy link

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label May 17, 2023
@timhoffm
Copy link
Member Author

Let's not follow up on this for now.

@timhoffm timhoffm closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: inactive Marked by the “Stale” Github Action
Projects
None yet
Development

No branches or pull requests

3 participants