320 def map_models(x):
321 return x[0], dict(map(lambda r: map_model_relations(r), x[1].items()))
322
323 return dict(map(lambda x: map_models(x), relationships.items())) 324
325 def get_model_columns_by_clean_name(self, MappedBase, mapper):
326 table = mapper.tables[0]
318 return clean_name(x[0]), x[1]
319
320 def map_models(x):
321 return x[0], dict(map(lambda r: map_model_relations(r), x[1].items())) 322
323 return dict(map(lambda x: map_models(x), relationships.items()))
324
870 data_selections = self.get_selections(info, ['data']) or []
871 data_names = list(map(lambda x: x.name.value, data_selections))
872 model_attrs = dict(map(lambda x: [clean_name(x), getattr(Model, x)], dir(Model)))
873 only_columns = list(filter(lambda x: x is not None, map(lambda x: model_attrs.get(x), field_names))) \ 874 if len(field_names) and 'allAttrs' not in data_names else None
875
876 queryset = self.get_queryset(request, Model, only_columns)
157 lookups.ENDS_WITH: {'operator': False, 'func': safe_endswith, 'pre_process': lambda x: safe_not_array(x)},
158 lookups.IS_NULL: {'operator': False, 'func': is_null, 'field_class': BooleanField, 'pre_process': lambda x: safe_not_array(x)},
159 lookups.IS_EMPTY: {'operator': False, 'func': is_empty, 'field_class': BooleanField, 'pre_process': lambda x: safe_not_array(x)},
160 lookups.JSON_ICONTAINS: {'operator': False, 'func': json_icontains, 'field_class': CharField, 'pre_process': lambda x: safe_not_array(x)},161 lookups.COVEREDBY: {'operator': False, 'func': coveredby, 'pre_process': lambda x: safe_not_array(x)}
162 }
163
152 lookups.LT: {'operator': '__lt__', 'pre_process': lambda x: safe_not_array(x)},
153 lookups.LTE: {'operator': '__le__', 'pre_process': lambda x: safe_not_array(x)},
154 lookups.ICONTAINS: {'operator': False, 'func': safe_icontains, 'pre_process': lambda x: safe_not_array(x)},
155 lookups.IN: {'operator': False, 'func': safe_in, 'field_kwargs': {'many': True}, 'pre_process': lambda x: safe_array(x)},156 lookups.STARTS_WITH: {'operator': False, 'func': safe_startswith, 'pre_process': lambda x: safe_not_array(x)},
157 lookups.ENDS_WITH: {'operator': False, 'func': safe_endswith, 'pre_process': lambda x: safe_not_array(x)},
158 lookups.IS_NULL: {'operator': False, 'func': is_null, 'field_class': BooleanField, 'pre_process': lambda x: safe_not_array(x)},
A lambda that calls a function without modifying any of its parameters is unnecessary. Python functions are first-class objects and can be passed around in the same way as the resulting lambda. It is recommended to remove the lambda and use the function directly.
It is preferred to use the function hash
directly as the lambda function calls the same function without any modifications.
Another reason to avoid the lambda function here is that it makes debugging difficult.
Lambdas show as <lambda>
in tracebacks, where functions will display the function’s name.
items = [1, 2, 3]
hashify = lambda x: hash(x)
hashed_items = map(hashify, items)
items = [1, 2, 3]
# pass the builtin `hash` instead of the wrapper `hashify`
hashed_items = map(hash, items)