← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1461484] Re: '@staticmethod' need to be used where 'self' is not used

 

I don't believe this should be a rule. This isn't java, and if we need
to use those methods from outside an instance of a class, we should
first evaluate whether it can be a regular function. If we really need
those functions to be attached to particular classes, then use
@staticmethod.

** Changed in: glance
       Status: New => Opinion

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to Glance.
https://bugs.launchpad.net/bugs/1461484

Title:
  '@staticmethod' need to be used where 'self' is not used

Status in OpenStack Image Registry and Delivery Service (Glance):
  Opinion

Bug description:
  https://github.com/openstack/glance/blob/master/glance/api/v1/members.py#L40

  def _check_can_access_image_members(self, context):
          if context.owner is None and not context.is_admin:
              raise webob.exc.HTTPUnauthorized(_("No authenticated user"))
  			
  In above method, 'self' is not used in _check_can_access_image_members() method that means we can mark this method as static. There are several places in the entire project where this change needs to be done.

To manage notifications about this bug go to:
https://bugs.launchpad.net/glance/+bug/1461484/+subscriptions


References