-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery suggested refactorings #41
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -568,12 +568,11 @@ async def _get_items(self, qs): | |
items, total = await multi(awaitables) | ||
# Set total items number | ||
pagination['total'] = total | ||
elif self.prefetch_queries: | ||
items = await self.application.objects.prefetch(qs, | ||
*self.prefetch_queries) | ||
else: | ||
if self.prefetch_queries: | ||
items = await self.application.objects.prefetch(qs, | ||
*self.prefetch_queries) | ||
else: | ||
items = await self.application.objects.execute(qs) | ||
items = await self.application.objects.execute(qs) | ||
Comment on lines
+571
to
+575
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
except (peewee.DataError, ValueError) as e: | ||
# Bad parameters | ||
raise HTTPError( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -218,10 +218,10 @@ def _get_properties(self, recurse=True): | |
if not recurse: | ||
return dict(self._properties) | ||
|
||
properties = {} | ||
for prop, subschema in self._properties.items(): | ||
properties[prop] = subschema.to_dict() | ||
return properties | ||
return { | ||
prop: subschema.to_dict() | ||
for prop, subschema in self._properties.items() | ||
} | ||
Comment on lines
-221
to
+224
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
def _get_items(self, recurse=True): | ||
if not recurse: | ||
|
@@ -294,8 +294,5 @@ def _generate_array(self, array): | |
self._add_items(array, 'add_object') | ||
|
||
def _generate_basic(self, val): | ||
if val in JS_TYPES.keys(): | ||
val_type = JS_TYPES[val] | ||
else: | ||
val_type = JS_TYPES[type(val)] | ||
val_type = JS_TYPES[val] if val in JS_TYPES.keys() else JS_TYPES[type(val)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
self._add_type(val_type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
perm_roles.wrap.func
refactored with the following changes: