-
Notifications
You must be signed in to change notification settings - Fork 1
Sourcery refactored main branch #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
base: main
Are you sure you want to change the base?
Conversation
|
elif a[key] == b[key]: | ||
pass # same leaf value | ||
else: | ||
raise Exception('Conflict at %s' % '.'.join(path + [str(key)])) | ||
elif a[key] != b[key]: | ||
raise Exception(f"Conflict at {'.'.join(path + [str(key)])}") |
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 merge
refactored with the following changes:
- Remove empty elif clause (
remove-pass-elif
) - Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
This removes the following comments ( why? ):
# same leaf value
print("WARNING: cannot find or use %s executable" % DECRYPT_TOOL, file=sys.stderr) | ||
print( | ||
f"WARNING: cannot find or use {DECRYPT_TOOL} executable", | ||
file=sys.stderr, | ||
) |
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 check_decrypt_tool
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
else: | ||
print("WARNING: NODE_BUILD_SECRETS defined but not a directory", file=sys.stderr) | ||
print("It must be the path to a local checkout of https://github.com/nodejs-private/secrets", file=sys.stderr) | ||
return None | ||
print("WARNING: NODE_BUILD_SECRETS defined but not a directory", file=sys.stderr) | ||
print("It must be the path to a local checkout of https://github.com/nodejs-private/secrets", file=sys.stderr) | ||
return 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 get_secrets_path
refactored with the following changes:
- Remove unnecessary else after guard condition (
remove-unnecessary-else
)
print("WARNING: cannot load %s" % file_name, file=sys.stderr) | ||
print(f"WARNING: cannot load {file_name}", file=sys.stderr) |
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 load_yaml_secrets
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
export[host_type] = {} | ||
export[host_type]['hosts'] = [] | ||
|
||
key = '~/.ssh/nodejs_build_%s' % host_type | ||
export[host_type] = {'hosts': []} | ||
key = f'~/.ssh/nodejs_build_{host_type}' |
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 parse_yaml
refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign
) - Replace interpolated string formatting with f-string [×2] (
replace-interpolation-with-fstring
) - Replace call to format with f-string (
use-fstring-for-formatting
) - Add single value to dictionary directly rather than using update() [×7] (
simplify-dictionary-update
) - Merge dictionary updates via the union operator (
dict-assign-update-to-union
)
hostinfo = dict() | ||
info = host.split('-') | ||
|
||
expected = ['type', 'provider', 'os', 'arch', 'uid'] | ||
|
||
if len(info) != 5: | ||
raise Exception('Host format is invalid: %s,' % host) | ||
|
||
for key, item in enumerate(expected): | ||
hostinfo[item] = has_metadata(info[key]) | ||
raise Exception(f'Host format is invalid: {host},') | ||
|
||
hostinfo = {item: has_metadata(info[key]) for key, item in enumerate(expected)} | ||
for item in ['type', 'provider', 'arch']: | ||
if hostinfo[item] not in valid[item]: | ||
raise Exception('Invalid %s: %s' % (item, hostinfo[item])) | ||
raise Exception(f'Invalid {item}: {hostinfo[item]}') |
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 parse_host
refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block
) - Replace
dict()
with{}
(dict-literal
) - Replace interpolated string formatting with f-string [×2] (
replace-interpolation-with-fstring
) - Convert for loop into dictionary comprehension (
dict-comprehension
)
filename = os.path.join(target_dir, '%s.remmina' % hostname) | ||
filename = os.path.join(target_dir, f'{hostname}.remmina') |
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 main
refactored with the following changes:
- Replace interpolated string formatting with f-string [×2] (
replace-interpolation-with-fstring
)
rendered = '{}{}{}'.format( | ||
pre_match, | ||
render_template(module.params['hostinfo']), | ||
post_match | ||
rendered = ( | ||
f"{pre_match}{render_template(module.params['hostinfo'])}{post_match}" |
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 main
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
) - Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
reader = geoip2.database.Reader(os.path.dirname(os.path.realpath(__file__)) + '/GeoLite2-City.mmdb') | ||
reader = geoip2.database.Reader( | ||
f'{os.path.dirname(os.path.realpath(__file__))}/GeoLite2-City.mmdb') |
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.
Lines 8-26
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Use named expression to simplify assignment and conditional (
use-named-expression
)
|
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!