-
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
311adba
to
5d73d60
Compare
match = functionNameRegex.match(line) | ||
if match: | ||
if match := functionNameRegex.match(line): |
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 matchFunctionName
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
isLastParameter = True if end is not None and end == ')' else False | ||
isLastParameter = end is not None and end == ')' |
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 matchParameter
refactored with the following changes:
- Simplify boolean if expression (
boolean-if-exp-identity
) - Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
)
return True if openingCurlyBraceRegex.match(line) is not None else False | ||
return openingCurlyBraceRegex.match(line) is not None |
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 matchOpeningCurlyBrace
refactored with the following changes:
- Simplify boolean if expression (
boolean-if-exp-identity
) - Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
)
if not matchOpeningCurlyBrace(nextLine): | ||
return 0 | ||
return i + 1 | ||
return 0 if not matchOpeningCurlyBrace(nextLine) else i + 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 getFunctionDeclarationLength
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
)
parameterInfos = [] | ||
for i in range(length): | ||
parameterInfos.append(matchParameter(remainingLines[i])) | ||
return parameterInfos | ||
return [matchParameter(remainingLines[i]) for i in range(length)] |
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 getParameterInfos
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
def get_random_file_index (): | ||
def get_random_file_index(): | ||
n = len (files) | ||
if n == 0: | ||
return -1 | ||
else: | ||
return random_gen.randrange (n) | ||
return -1 if n == 0 else random_gen.randrange (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 get_random_file_index
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
def get_random_directory_index (): | ||
def get_random_directory_index(): | ||
n = len (directories) | ||
if n == 0: | ||
return -1 | ||
else: | ||
return random_gen.randrange (n) | ||
|
||
def get_random_filename (): | ||
chars = [] | ||
for i in range (20): | ||
chars.append ("abcdefghijklmnopqrstuvwxyz"[random_gen.randrange (26)]) | ||
return -1 if n == 0 else random_gen.randrange (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 get_random_directory_index
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
def get_random_filename (): | ||
chars = [] | ||
for i in range (20): | ||
chars.append ("abcdefghijklmnopqrstuvwxyz"[random_gen.randrange (26)]) | ||
return -1 if n == 0 else random_gen.randrange (n) | ||
|
||
def get_random_filename(): | ||
chars = [ | ||
"abcdefghijklmnopqrstuvwxyz"[random_gen.randrange(26)] | ||
for _ in range(20) | ||
] | ||
extension = extensions[random_gen.randrange (len (extensions))] | ||
filename = "".join (chars) + extension | ||
return filename | ||
return "".join (chars) + extension |
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_random_filename
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
) - Replace unused for index with underscore (
for-index-underscore
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
The mutter portion of the comment isn't relavent after [1] and #1 was resolved in [2] [1] https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/179 [2] https://gitlab.gnome.org/GNOME/nautilus/-/merge_requests/630
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!