Skip to content
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

Open
wants to merge 1 commit into
base: 1.1
Choose a base branch
from
Open

Sourcery refactored 1.1 branch #1

wants to merge 1 commit into from

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Apr 19, 2023

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:

git fetch origin sourcery/1.1
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from ntp3phat April 19, 2023 16:01
@@ -2,6 +2,7 @@

"""Print current tinc version for using in build scripts."""

Copy link
Author

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:

Comment on lines -39 to +45
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")
]:
Copy link
Author

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:

if not (int(version[0]) >= 3 and int(version[1]) >= 3):
if int(version[0]) < 3 or int(version[1]) < 3:
Copy link
Author

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)

Comment on lines -66 to +67
assert not foo_bar == empty
assert not bar_foo == empty
assert foo_bar != empty
assert bar_foo != empty
Copy link
Author

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."""

Copy link
Author

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:

Comment on lines -89 to +86
if link_type in ("tun", "tap"):
if link_type in {"tun", "tap"}:
Copy link
Author

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:

file = logging.FileHandler(os.path.join(_log_dir, name + ".log"))
file = logging.FileHandler(os.path.join(_log_dir, f"{name}.log"))
Copy link
Author

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:

Comment on lines -32 to +35
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()
)
Copy link
Author

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)
Copy link
Author

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:

euid = os.geteuid()
if euid:
if euid := os.geteuid():
Copy link
Author

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
0 participants