Giter VIP home page Giter VIP logo

Comments (9)

NeilGirdhar avatar NeilGirdhar commented on June 16, 2024

@rmorshea These are bugs that need to be fixed please by the way. This is a basic requirement of multiple inheritance in Python.

from traitlets.

rmorshea avatar rmorshea commented on June 16, 2024
  1. I think super().__init__ is left out because HasTraits inherits from object.
  2. If I'm right this change in #173 is the positional argument problem you mentioned?
  3. Value setting from kwargs in HasTraits.__init__ isn't something I'm attached to, but others probably are, and I imagine it'd represent a pretty big API breakage that would have to come in v5.0 if it were to come at all.

from traitlets.

NeilGirdhar avatar NeilGirdhar commented on June 16, 2024
  1. That doesn't matter. A class can inherit from HasTraits and something else, which is why you must call super. E.g.

    class B:
       def __init__(self, *, x, **kwargs):
           super().__init__(**kwargs)
           self.y = f(x)
    
    class A(HasTraits, B):
        pass
    

    is broken. B.__init__ is never called.

  2. Yes, thank you!

  3. This breaks multiple inheritance. I personally don't think it's good Python. The only class that does this is dict, and I think that was a mistake that's unfortunately too late to fix. However, it is not too late for traitlets.

from traitlets.

rmorshea avatar rmorshea commented on June 16, 2024

@NeilGirdhar - see #174

from traitlets.

rmorshea avatar rmorshea commented on June 16, 2024

As for the value setting with kwargs, I'd create a separate issue for it and ping minrk, ellisonbg, and SylvainCorlay. I'm not sure what their reasons have been for keeping it so I can't speak for them on that.

from traitlets.

NeilGirdhar avatar NeilGirdhar commented on June 16, 2024

@rmorshea Okay thanks. Note that unless you forward the kwargs to the super call in #174, my example above is still broken since x will be swallowed before it ever reaches B.__init__.

from traitlets.

rmorshea avatar rmorshea commented on June 16, 2024

@NeilGirdhar, unfortunately you can't do that since object.__init__ doesn't accept any args or kwargs.

from traitlets.

NeilGirdhar avatar NeilGirdhar commented on June 16, 2024

@rmorshea You just forward the args and kwargs. If none of the superclasses consume them, then you're right that object.__init__ will raise. If there are none left, then there is no problem. This is how cooperative multiple inheritance works in Python.

from traitlets.

minrk avatar minrk commented on June 16, 2024

Args are passed through to super in #175

from traitlets.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.