getattr
PTC-W0034getattr
is missing a default value 31 model_field = getattr(self.get_model(request), self.lookup_field)
32
33 try:
34 field_lookup = getattr(model_field, '__eq__') 35
36 lookup_value = request.path_kwargs[lookup_url_kwarg]
37 data_type = get_column_data_type(model_field)
getattr
is missing a default value 9
10def save_extra_data(backend, user, response, details, strategy, *args, **kwargs):
11 extra_data = backend.extra_data(user, 0, response, details, *args, **kwargs)
12 sso = configuration.clean_sso_application_name(getattr(backend, 'sso'))13 extra_data_key = '_'.join(['extra_data', sso])
14
15 data = {
getattr
is being used to check if an attribute exists, without specifying a default value.
Missing a default to getattr
will cause an AttributeError
to be raised for non-existent properties, which is the same as when a non-existent property is accessed directly.
It is recommended to either provide a default value to be returned by getattr
if the attribute is not found, or access the attribute directly as there is no additional safety in using getattr
if the attribute name is known ahead of time.