Errors detected in .deepsource.toml
.
24 azure_container = getattr(settings, 'AZURE_MEDIA_STORAGE_CONTAINER', None) or 'media'
25 override_hostname = getattr(settings, 'AZURE_MEDIA_STORAGE_HOSTNAME', None)
26
27 def url(self, name, expire=None, http_method=None): # noqa28 """
29 Override to accept ``http_method`` and ignore it.
30
2
3class BuildMediaFileSystemStorageTest(BuildMediaFileSystemStorage):
4
5 def exists(self, *args, **kargs):6 return True
209 team=self.name,
210 )
211
212 def save(self, *args, **kwargs): # pylint: disable=signature-differs213 if not self.slug:
214 self.slug = slugify(self.name)
215 super().save(*args, **kwargs)
250 team=self.team,
251 )
252
253 def save(self, *args, **kwargs): # pylint: disable=signature-differs254 hash_ = salted_hmac(
255 # HMAC key per applications
256 '.'.join([self.__module__, self.__class__.__name__]),
99 def members(self):
100 return AdminPermission.members(self)
101
102 def save(self, *args, **kwargs): # pylint: disable=signature-differs103 if not self.slug:
104 self.slug = slugify(self.name)
105
The parameters in the overridden method don't match the method defined in the parent class. There are three possible scenarios for this:
Python will allow this, but if the overridden method is intended to be executed from external code, you may want to reconsider this. Overriding a method without ensuring that both methods accept the same name, number, and order of parameters has the potential to cause an error when the overriding method is called with parameters that is illegal for the overridden method. This violates the Liskov substitution principle.
class Base:
def summation(cycle, x, y, z):
log(cycle)
return x + y + z
class UneqalArgLen(Base):
def summation(cycle, x, y):
log(cycle)
return x + y
class RenamedArg(Base):
def summation(cycle, x, y, zee=None):
log(cycle)
return x + y
class unorderdArgs(Base):
def summation(x, cycle, y, z):
log(cycle)
return x + y + z
There can be multiple approaches to address this inconsistency. The first approach is to re-think the method signature in the parent class itself if the child classes are expected to implement a variable number of arguments in their own implementation. If the exploitation here is a special case, this can be dealt with making it compatible with the parent's class method signature, like this:
class Base:
def summation(cycle, x, y, z):
log(cycle)
return x + y + z
class FixedUneqalArgLen(Base):
def summation(cycle, x, y, z=None):
log(cycle)
return x + y
class NoRenamedArg(Base):
def summation(cycle, x, y, _): # using `_` won't trigger the issue.
log(cycle)
return x + y
class NounorderdArgs(Base):
def summation(cycle, x, y, z): # No surprises here
log(cycle)
return x + y + z