Skip to content
Snippets Groups Projects

Fix deprecations and super usage

Merged Amir MOHAMMADI requested to merge load into master
All threads resolved!

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • André Anjos resolved all discussions

    resolved all discussions

  • merged

  • André Anjos mentioned in commit 06a10a02

    mentioned in commit 06a10a02

  • thank you for your time.

  • The changes that I did here in super broke bob.bio.base and bob.pad.base

  • mentioned in merge request bob.bio.base!118 (merged)

  • Pavel KORSHUNOV
    Pavel KORSHUNOV @pkorshunov started a thread on commit e83d24d5
  • 29 29 The extension of raw data files, e.g. ``.png``.
    30 30 """
    31 31
    32 def __init__(self, original_directory, original_extension):
    • @amohammadi Do you know what is the reason to put call to super() here when the FileDatabase just extends object? I get a complain that object.__init__() takes no parameters

    • That's how super works ...

      class A(object):
          def __init__(self, A1, **kwargs):
              print('init of A is called with kwargs {}'.format(kwargs))
              super(A, self).__init__(**kwargs)
              self.A1 = A1
      
      
      class B(object):
          def __init__(self, B1, **kwargs):
              print('init of B is called with kwargs {}'.format(kwargs))
              super(B, self).__init__(**kwargs) # <-- this will not call object.__init__ but it will call A.__init__
              self.B1 = B1
      
      
      class C(B, A):
          def __init__(self, **kwargs):
              print('init of C is called with kwargs {}'.format(kwargs))
              super(C, self).__init__(**kwargs)
      
      
      c = C(A1='A1', B1='B1')

      you will get:

      init of C is called with kwargs {'A1': 'A1', 'B1': 'B1'}
      init of B is called with kwargs {'A1': 'A1'}
      init of A is called with kwargs {}
    • As you can see above B just extends object but when super is used it will actually call A.__init__ without having to know about it. So you think B will call object but in reality it will call A when you have diamond shaped inheritance like here:

         object
         /     \
        /       \
      A          B
        \       /
         \     /
            C
      Edited by Amir MOHAMMADI
    • ok, I see. Thanks. It was the problem from ijba but I think you fixed it already.

    • @pkorshunov just make sure you don't pass extra arguments to this class if it is not really needed. You can see how I fixed this issue in bob.bio.base!118 (diffs)

    • Yes it is fixed in bob.bio.face

      Edited by Amir MOHAMMADI
    • Please register or sign in to reply
    Please register or sign in to reply
    Loading