staticmethod
argument detected PYL-W021132 return f'{self.event.name}'
33
34 @staticmethod
35 def format_sent_to(self):36 return f'{self.user.fullname} <{self.user.email}>'
37
38
28 sent_to = fields.Method('format_sent_to')
29
30 @staticmethod
31 def format_event_name(self):32 return f'{self.event.name}'
33
34 @staticmethod
It is customary for instance or class methods to take self
or cls
, respectively, as their first arguments, a method that uses either of these names but is found to be a static method may have been defined incorrectly. Choose names other than self
or cls
for arguments to avoid confusing other programmers looking at your code.
class API:
@staticmethod
def get_endpoint(self): # The `self` here can be confusing
return self + '/api/v2/users'
class API:
@staticmethod
def get_endpoint(origin): # Any other, more suitable variable name
return origin + '/api/v2/users'