Sourcery Starbot ⭐ refactored BQBB/05-commerce#1
Open
SourceryAI wants to merge 1 commit intoBQBB:mainfrom
Open
Sourcery Starbot ⭐ refactored BQBB/05-commerce#1SourceryAI wants to merge 1 commit intoBQBB:mainfrom
SourceryAI wants to merge 1 commit intoBQBB:mainfrom
Conversation
SourceryAI
commented
Jul 15, 2023
| except User.DoesNotExist: | ||
| return email | ||
| raise forms.ValidationError("Email '%s' already in use." % email) | ||
| raise forms.ValidationError(f"Email '{email}' already in use.") |
Author
There was a problem hiding this comment.
Function AccountUpdateForm.clean_email refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| class CustomUserManager(UserManager): | ||
| def get_by_natural_key(self, username): | ||
| case_insensitive_username_field = '{}__iexact'.format(self.model.USERNAME_FIELD) | ||
| case_insensitive_username_field = f'{self.model.USERNAME_FIELD}__iexact' |
Author
There was a problem hiding this comment.
Function CustomUserManager.get_by_natural_key refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
Comment on lines
-112
to
+114
| addresses = Address.objects.select_related('city', 'user').filter(user=User.objects.get(id=request.auth['pk'])) | ||
| if addresses: | ||
| if addresses := Address.objects.select_related('city', 'user').filter( | ||
| user=User.objects.get(id=request.auth['pk']) | ||
| ): |
Author
There was a problem hiding this comment.
Function list_addresses refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression)
Comment on lines
-128
to
+129
| cities_qs = City.objects.all() | ||
|
|
||
| if cities_qs: | ||
| if cities_qs := City.objects.all(): |
Author
There was a problem hiding this comment.
Function list_cities refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression)
Comment on lines
-191
to
+192
| cart_items = Item.objects.filter(user=User.objects.get(id=request.auth['pk']), ordered=False) | ||
|
|
||
| if cart_items: | ||
| if cart_items := Item.objects.filter( | ||
| user=User.objects.get(id=request.auth['pk']), ordered=False | ||
| ): |
Author
There was a problem hiding this comment.
Function view_cart refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression)
| if self.parent: | ||
| return f'- {self.name}' | ||
| return f'{self.name}' | ||
| return f'- {self.name}' if self.parent else f'{self.name}' |
Author
There was a problem hiding this comment.
Function Category.__str__ 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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
mainbranch, then run: