Skip to content

Commit 8833168

Browse files
committed
introduce ruff formatting
1 parent 171c21c commit 8833168

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

.github/workflows/ci.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
python:
11+
name: Lint Python
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Install black
16+
run: pip install ruff
17+
- name: Check style
18+
run: ruff format --quiet --line-length 120 --diff */*.py *.py
19+
- name: Lint
20+
run: ruff check */*.py *.py

pyinfra_borgbackup/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ def deploy_borgbackup(
5656
if borg_repo.startswith("hetzner-backup:"):
5757
files.put(
5858
name="create SSH config",
59-
src=importlib.resources.files(__package__)
60-
.joinpath("dot_ssh", "config")
61-
.open("rb"),
59+
src=importlib.resources.files(__package__).joinpath("dot_ssh", "config").open("rb"),
6260
dest="/root/.ssh/config",
6361
user="root",
6462
group="root",
@@ -113,8 +111,8 @@ def deploy_borgbackup(
113111
src=importlib.resources.files(__package__).joinpath("borgbackup.timer.j2"),
114112
dest="/etc/systemd/system/borgbackup.timer",
115113
mode="644",
116-
minute = str(random.randint(0, 59)),
117-
hour = str(random.randint(0, 4)),
114+
minute=str(random.randint(0, 59)),
115+
hour=str(random.randint(0, 4)),
118116
)
119117
systemd.service(
120118
name="Setup borgbackup timer",

pyinfra_borgbackup/backup-pre.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
def cmd(command: str) -> int:
8-
"""Run a command and return its exit code. """
8+
"""Run a command and return its exit code."""
99
return os.waitstatus_to_exitcode(os.system(command))
1010

1111

@@ -27,8 +27,6 @@ def cmd(command: str) -> int:
2727
if user == "root":
2828
returncode = cmd(f"systemctl {args.command} {services[user]}")
2929
else:
30-
returncode = cmd(
31-
f"su -l {user} -c 'systemctl --user {args.command} {services[user]}'"
32-
)
30+
returncode = cmd(f"su -l {user} -c 'systemctl --user {args.command} {services[user]}'")
3331
if returncode != 0:
3432
print(f"WARNING: Failed to {args.command} {services[user]} as {user} user")

0 commit comments

Comments
 (0)