-
Notifications
You must be signed in to change notification settings - Fork 1
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 Starbot ⭐ refactored ilyeshammadi/django-publishable #6
base: develop
Are you sure you want to change the base?
Conversation
if not DraftController.is_draft: | ||
return queryset.filter(type=TYPES.PUBLISHED) | ||
return queryset.filter(type=TYPES.DRAFT, is_deleted=False) | ||
return ( | ||
queryset.filter(type=TYPES.DRAFT, is_deleted=False) | ||
if DraftController.is_draft | ||
else queryset.filter(type=TYPES.PUBLISHED) | ||
) |
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 select_from_queryset
refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
) - Swap if/else branches of if expression to remove negation (
swap-if-expression
)
# Delete the previous published to save space | ||
previous_published_id = None | ||
if self.published: | ||
previous_published_id = self.published.id | ||
|
||
previous_published_id = self.published.id if self.published else None |
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 Publishable.publish
refactored with the following changes:
- Move setting of default value for variable into
else
branch (introduce-default-else
) - Replace if statement with if expression (
assign-if-exp
)
This removes the following comments ( why? ):
# Delete the previous published to save space
else: | ||
self.is_deleted = True | ||
self.save() | ||
self.is_deleted = True | ||
self.save() |
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 Publishable.delete
refactored with the following changes:
- Swap positions of nested conditionals [×2] (
swap-nested-ifs
) - Hoist nested repeated code outside conditional statements [×2] (
hoist-similar-statement-from-if
) - Swap if/else branches [×2] (
swap-if-else-branches
) - Remove unnecessary else after guard condition (
remove-unnecessary-else
)
if Draft.objects.filter(object_id=self.id).exists(): | ||
draft = Draft.objects.get(object_id=self.id) | ||
else: | ||
draft = Draft.objects.create(content_object=self) | ||
return draft | ||
return ( | ||
Draft.objects.get(object_id=self.id) | ||
if Draft.objects.filter(object_id=self.id).exists() | ||
else Draft.objects.create(content_object=self) | ||
) |
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 Publishable.broadcast_need_to_published
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
develop
branch, then run: