-
Notifications
You must be signed in to change notification settings - Fork 2
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 BQBB/05-commerce #1
base: main
Are you sure you want to change the base?
Conversation
raise forms.ValidationError("Email '%s' already in use." % email) | ||
raise forms.ValidationError(f"Email '{email}' already in use.") |
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 AccountUpdateForm.clean_email
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
case_insensitive_username_field = '{}__iexact'.format(self.model.USERNAME_FIELD) | ||
case_insensitive_username_field = f'{self.model.USERNAME_FIELD}__iexact' |
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 CustomUserManager.get_by_natural_key
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
)
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']) | ||
): |
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 list_addresses
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
cities_qs = City.objects.all() | ||
|
||
if cities_qs: | ||
if cities_qs := City.objects.all(): |
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 list_cities
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
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 | ||
): |
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 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}' |
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 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
)
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
main
branch, then run: