-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored master branch #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
base: master
Are you sure you want to change the base?
Conversation
|
|
||
| def save(self, *args, **kwargs): | ||
| if self.full_name == "" or self.full_name == None: | ||
| if self.full_name == "" or self.full_name is 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 Profile.save refactored with the following changes:
- Use x is None rather than x == None (
none-compare)
| def sender_profile(self): | ||
| sender_profile = Profile.objects.get(user=self.sender) | ||
| return sender_profile | ||
| return Profile.objects.get(user=self.sender) |
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 ChatMessage.sender_profile refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| reciever_profile = Profile.objects.get(user=self.reciever) | ||
| return reciever_profile | ||
| return Profile.objects.get(user=self.reciever) |
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 ChatMessage.reciever_profile refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| self.Meta.depth = 0 | ||
| else: | ||
| self.Meta.depth = 3 | ||
| self.Meta.depth = 0 if request and request.method=='POST' else 3 |
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 ProfileSerializer.__init__ refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| if request and request.method=='POST': | ||
| self.Meta.depth = 0 | ||
| else: | ||
| self.Meta.depth = 2 | ||
| self.Meta.depth = 0 if request and request.method=='POST' else 2 |
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 MessageSerializer.__init__ refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
|
|
||
| todo = Todo.objects.filter(user=user) | ||
| return todo | ||
| return Todo.objects.filter(user=user) |
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 TodoListView.get_queryset refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| todo = Todo.objects.get(id=todo_id, user=user) | ||
|
|
||
| return todo | ||
| return Todo.objects.get(id=todo_id, user=user) |
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 TodoDetailView.get_object refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| messages = ChatMessage.objects.filter( | ||
| id__in = Subquery( | ||
| return ChatMessage.objects.filter( | ||
| id__in=Subquery( | ||
| User.objects.filter( | ||
| Q(sender__reciever=user_id) | | ||
| Q(reciever__sender=user_id) | ||
| ).distinct().annotate( | ||
| Q(sender__reciever=user_id) | Q(reciever__sender=user_id) | ||
| ) | ||
| .distinct() | ||
| .annotate( | ||
| last_msg=Subquery( | ||
| ChatMessage.objects.filter( | ||
| Q(sender=OuterRef('id'),reciever=user_id) | | ||
| Q(reciever=OuterRef('id'),sender=user_id) | ||
| ).order_by('-id')[:1].values_list('id',flat=True) | ||
| Q(sender=OuterRef('id'), reciever=user_id) | ||
| | Q(reciever=OuterRef('id'), sender=user_id) | ||
| ) | ||
| .order_by('-id')[:1] | ||
| .values_list('id', flat=True) | ||
| ) | ||
| ).values_list('last_msg', flat=True).order_by("-id") | ||
| ) | ||
| .values_list('last_msg', flat=True) | ||
| .order_by("-id") | ||
| ) | ||
| ).order_by("-id") | ||
|
|
||
| return messages |
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 MyInbox.get_queryset refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| messages = ChatMessage.objects.filter(sender__in=[sender_id, reciever_id], reciever__in=[sender_id, reciever_id]) | ||
| return messages | ||
| return ChatMessage.objects.filter( | ||
| sender__in=[sender_id, reciever_id], | ||
| reciever__in=[sender_id, reciever_id], | ||
| ) |
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 GetMessages.get_queryset refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
Branch
masterrefactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
masterbranch, then run:Help us improve this pull request!