-
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 master branch #1
base: master
Are you sure you want to change the base?
Conversation
if text.startswith(prefix): | ||
return text[len(prefix):] | ||
return text | ||
return text[len(prefix):] if text.startswith(prefix) else text |
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 remove_prefix
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
)
vcf = "BEGIN:VCARD" | ||
vcf += "\n" | ||
vcf = "BEGIN:VCARD" + "\n" |
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 vCard_gen
refactored with the following changes:
- Replace assignment and augmented assignment with single assignment (
merge-assign-and-aug-assign
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
@@ -90,7 +87,6 @@ def teardown_request(exception): | |||
|
|||
|
|||
@app.route('/') | |||
# @ldap.login_required |
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 index
refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block
) - Convert for loop into list comprehension (
list-comprehension
)
This removes the following comments ( why? ):
# if str(username).casefold() == str(row[9]).casefold():
# @ldap.login_required
# login_id = row[0]
return render_template('phonebook.html', people=people, login_id=login_id, admin=admin) | ||
|
||
|
||
@app.route('/new', endpoint='edit', methods=['GET', 'POST']) | ||
@app.route('/edit/<id>', methods=['GET', 'POST']) | ||
# @ldap.login_required |
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 edit
refactored with the following changes:
- Merge else clause's nested if statement into elif (
merge-else-if-into-elif
)
This removes the following comments ( why? ):
# @ldap.login_required
# @ldap.login_required | ||
def delete(id): | ||
username = remove_prefix(session['user_id'], 'MAIN\\') | ||
if username in admin_users: | ||
admin = True | ||
else: | ||
admin = False | ||
admin = username in admin_users |
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 delete
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
) - Simplify boolean if expression (
boolean-if-exp-identity
) - Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
)
This removes the following comments ( why? ):
# @ldap.login_required
else: | ||
session['user_id'] = remove_prefix(request.form['user'], conf_domain + '\\') | ||
return redirect('/') | ||
session['user_id'] = remove_prefix(request.form['user'], conf_domain + '\\') | ||
return redirect('/') |
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 login
refactored with the following changes:
- Remove unnecessary else after guard condition (
remove-unnecessary-else
)
# @ldap.login_required | ||
def vCard_all(): | ||
cur = g.db.execute( | ||
'SELECT id, position, lastname, firstname, middlename, intphone, cellphone, email, birthday, login FROM persons WHERE active ORDER BY lastname') | ||
people = [] | ||
for row in cur.fetchall(): | ||
people.append({ | ||
people = [ | ||
{ |
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 vCard_all
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
) - Use str.join() instead of for loop (
use-join
)
This removes the following comments ( why? ):
# @ldap.login_required
Branch
master
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
master
branch, then run:Help us improve this pull request!