-
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 1.1 branch #1
base: 1.1
Are you sure you want to change the base?
Conversation
@@ -2,6 +2,7 @@ | |||
|
|||
"""Print current tinc version for using in build scripts.""" | |||
|
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 19-19
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
if not "UP" in line["flags"]: | ||
if "UP" not in line["flags"]: | ||
continue | ||
local: T.List[str] = [] | ||
for addr in line["addr_info"]: | ||
if addr["family"] in ("inet", "inet6"): | ||
local.append(addr["local"]) | ||
if local: | ||
if local := [ | ||
addr["local"] | ||
for addr in line["addr_info"] | ||
if addr["family"] in ("inet", "inet6") | ||
]: |
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_interfaces
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
) - Simplify logical expression using De Morgan identities (
de-morgan
) - Use named expression to simplify assignment and conditional (
use-named-expression
)
if not (int(version[0]) >= 3 and int(version[1]) >= 3): | ||
if int(version[0]) < 3 or int(version[1]) < 3: |
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 try_rsa_keys
refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan
)
assert not foo_bar == empty | ||
assert not bar_foo == empty | ||
assert foo_bar != empty | ||
assert bar_foo != empty |
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 run_keys_test
refactored with the following changes:
- Simplify logical expression using De Morgan identities [×2] (
de-morgan
)
@@ -2,6 +2,7 @@ | |||
|
|||
"""Test that all tincd scripts execute in correct order and contain expected env vars.""" | |||
|
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 17-19
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
)
if link_type in ("tun", "tap"): | ||
if link_type in {"tun", "tap"}: |
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 link_add
refactored with the following changes:
- Use set when checking membership of a collection of literals (
collection-into-set
)
file = logging.FileHandler(os.path.join(_log_dir, name + ".log")) | ||
file = logging.FileHandler(os.path.join(_log_dir, f"{name}.log")) |
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 new_logger
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
for key, val in env.items(): | ||
if not val or (key != "TEST_NAME" and not os.path.isfile(val)): | ||
return False | ||
return True | ||
return not any( | ||
not val or (key != "TEST_NAME" and not os.path.isfile(val)) | ||
for key, val in env.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 _check
refactored with the following changes:
- Use any() instead of for loop (
use-any
)
for token in tokens: | ||
features.append(Feature(token)) | ||
features.extend(Feature(token) for token in tokens) |
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 Tinc.features
refactored with the following changes:
- Replace a for append loop with list extend (
for-append-to-extend
)
euid = os.geteuid() | ||
if euid: | ||
if euid := os.geteuid(): |
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 require_root
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
Branch
1.1
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
1.1
branch, then run:Help us improve this pull request!