-
Notifications
You must be signed in to change notification settings - Fork 0
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 refactored main branch #1
base: main
Are you sure you want to change the base?
Conversation
encoder.update(custom_encoder) | ||
encoder |= custom_encoder |
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 jsonable_encoder
refactored with the following changes:
- Merge dictionary updates via the union operator (
dict-assign-update-to-union
) - Convert for loop into list comprehension (
list-comprehension
) - Remove unnecessary else after guard condition (
remove-unnecessary-else
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
user_id = re.match(r"^/users/(\d+)", pathname).group(1) | ||
user_id = re.match(r"^/users/(\d+)", pathname)[1] |
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 route
refactored with the following changes:
- Replace m.group(x) with m[x] for re.Match objects (
use-getitem-for-re-match-groups
)
trigger_id = triggered[0]["prop_id"].split(".")[0] | ||
if trigger_id: | ||
if trigger_id := triggered[0]["prop_id"].split(".")[0]: |
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 get_trigger_index
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
else: | ||
if request.method == "POST": | ||
db = SessionLocal() | ||
email = request.form.get("email") | ||
password = request.form.get("password") | ||
rememberMe = request.form.get("rememberMe") is not None | ||
try: | ||
user = CRUDUser.authenticate(db, email=email, password=password) | ||
if user: | ||
login_user(user, remember=rememberMe) | ||
return redirect("/") | ||
finally: | ||
db.close() | ||
error = True | ||
return render_template("login.html", error=error) | ||
if request.method == "POST": | ||
db = SessionLocal() | ||
email = request.form.get("email") | ||
password = request.form.get("password") | ||
rememberMe = request.form.get("rememberMe") is not None | ||
try: | ||
user = CRUDUser.authenticate(db, email=email, password=password) | ||
if user: | ||
login_user(user, remember=rememberMe) | ||
return redirect("/") | ||
finally: | ||
db.close() | ||
error = True | ||
return render_template("login.html", error=error) |
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 FlaskLogin.__init__
refactored with the following changes:
- Remove unnecessary else after guard condition (
remove-unnecessary-else
)
if self.is_authorized(): | ||
return f(*args, **kwargs) | ||
else: | ||
return self.login_request() | ||
return f(*args, **kwargs) if self.is_authorized() else self.login_request() |
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 FlaskLogin.auth_wrapper
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
if v == "": | ||
return None | ||
return v | ||
return None if v == "" else v |
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 UserBase.passwords_match
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
)
if v == "": | ||
return None | ||
return v | ||
return None if v == "" else v |
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 UserUpdate.password_pre
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
)
if v == "": | ||
return None | ||
return v | ||
return None if v == "" else v |
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 UserUpdate.password2_pre
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
)
user = CRUDUser.get_by_email(db, email=email) | ||
if user: | ||
if user := CRUDUser.get_by_email(db, email=email): |
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 create_user
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
user_id = re.match(r"^/users/(\d+)", pathname).group(1) | ||
user_id = re.match(r"^/users/(\d+)", pathname)[1] |
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 update_user
refactored with the following changes:
- Replace m.group(x) with m[x] for re.Match objects (
use-getitem-for-re-match-groups
)
Branch
main
refactored 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
main
branch, then run:Help us improve this pull request!