-
Notifications
You must be signed in to change notification settings - Fork 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
Runs Ruff Formatting Over Project (Sourcery refactored) #207
Conversation
if not word.isupper(): | ||
if ( | ||
if word.isupper(): | ||
updated_words.append(word) | ||
elif ( | ||
len(word.strip()) >= 4 or word in capitalized_exceptions | ||
) and word not in uncapitalized_exceptions: | ||
updated_words.append(word.title()) | ||
elif ( | ||
len(word.strip()) < 4 or word in uncapitalized_exceptions | ||
) and word not in capitalized_exceptions: | ||
updated_words.append(word.lower()) | ||
else: | ||
updated_words.append(word) | ||
updated_words.append(word.title()) | ||
elif ( | ||
len(word.strip()) < 4 or word in uncapitalized_exceptions | ||
) and word not in capitalized_exceptions: | ||
updated_words.append(word.lower()) |
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 PostForm.clean_title
refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches
) - Merge else clause's nested if statement into elif (
merge-else-if-into-elif
)
cleaned_query = search.cleanup_string(initial_query) | ||
if cleaned_query: | ||
if cleaned_query := search.cleanup_string(initial_query): |
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 SearchResultsView.get_queryset
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
s: str = "" | ||
for key, value in vowel_freq.items(): | ||
s += key * value | ||
s: str = "".join(key * value for key, value in vowel_freq.items()) |
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 GameSetup.get_weighted_vowels
refactored with the following changes:
- Use str.join() instead of for loop (
use-join
)
s: str = "" | ||
for key, value in consonant_freq.items(): | ||
s += key * value | ||
s: str = "".join(key * value for key, value in consonant_freq.items()) |
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 GameSetup.get_weighted_consonants
refactored with the following changes:
- Use str.join() instead of for loop (
use-join
)
definition = ( | ||
f"The definition for '{word}' cannot be found " + "in the Oxford Dictionaries API." | ||
) | ||
definition = f"The definition for '{word}' cannot be found in the Oxford Dictionaries API." |
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 lookup_definition_data
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
return [line for line in file.readlines()] | ||
return list(file.readlines()) |
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 read_log_file
refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension
)
results = [] | ||
for area in area_results: | ||
results.append(area) | ||
|
||
results = list(area_results) |
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_area_results
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
) - Replace identity comprehension with call to collection constructor (
identity-comprehension
)
user_passes_auth = self.authenticate_user(user=user) | ||
if user_passes_auth: | ||
if user_passes_auth := self.authenticate_user(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 UserLoginView.handle_email_auth_user
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
context["redacted_user_email"] = f"{email[0:2]}**********@{domain}" | ||
context["redacted_user_email"] = f"{email[:2]}**********@{domain}" |
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 UserSetupEmailTokenView.get_context_data
refactored with the following changes:
- Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] (
remove-redundant-slice-index
)
def good_data_with_image(test_image): | ||
return { | ||
"profile_picture": test_image, | ||
"author_view": 0, | ||
"validity": True, | ||
} | ||
def good_data_with_image(self): | ||
return {"profile_picture": self, "author_view": 0, "validity": True} |
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 TestProfileUpdateForm.good_data_with_image
refactored with the following changes:
- The first argument to instance methods should be
self
(instance-method-first-arg-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.
Changes recommended by Sourcery can be accepted.
Pull Request #206 refactored by Sourcery.
If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.
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
develop
branch, then run:Help us improve this pull request!