-
Notifications
You must be signed in to change notification settings - Fork 7
Sourcery suggested refactorings #41
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
base: master
Are you sure you want to change the base?
Sourcery suggested refactorings #41
Conversation
Sourcery refactored this code to make it cleaner and more readable. If you want Sourcery to review the full project or all new pull requests, add [Sourcery](https://github.com/sourcery-ai/sourcery) to your repo. We try to only open PRs that are helpful. If this isn't helpful or you have any feedback for us - please [let us know](mailto:[email protected])!
valid_permission = False | ||
for r in roles: | ||
if r in items: | ||
valid_permission = True | ||
break | ||
valid_permission = any(r in items for r in roles) |
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:
- Use any() instead of for loop (use-any)
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) |
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 ApiListHandler._get_items
refactored with the following changes:
- Merge else clause's nested if statement into elif (merge-else-if-into-elif)
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() | ||
} |
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 Schema._get_properties
refactored with the following changes:
- Convert for loop into dictionary comprehension (dict-comprehension)
- Inline variable that is immediately returned (inline-immediately-returned-variable)
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Function Schema._generate_basic
refactored with the following changes:
- Replace if statement with if expression (assign-if-exp)
Sourcery refactored this code to make it cleaner and more readable.
If you want Sourcery to review the full project or all new pull requests, add Sourcery to your repo.
We try to only open PRs that are helpful. If this isn't helpful or you have any feedback for us - please let us know!