Skip to content

Commit 5492c30

Browse files
committed
chore: clean pre-commit
1 parent 50199e2 commit 5492c30

19 files changed

Lines changed: 64 additions & 49 deletions

.pre-commit-config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ repos:
1111
- id: check-symlinks
1212
- id: check-json
1313
- id: check-yaml
14+
# Overlays are deliberately multi-doc
15+
exclude: "^tests/integration/bundle/test-overlays/.*multi.*yaml$"
1416
- id: check-toml
1517
- id: mixed-line-ending
1618
- id: end-of-file-fixer
1719
exclude: "^juju/client/schemas-juju.*json$"
1820
- id: trailing-whitespace
1921
- id: detect-private-key
22+
exclude: "^tests/.*$"
2023
# Run the Ruff linter.
2124
- repo: https://github.com/astral-sh/ruff-pre-commit
2225
rev: v0.7.3

docs/_extensions/automembersummary.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ def run(self):
5858
lines.append(row(link))
5959
lines.append(divider)
6060
for line in summary:
61-
lines.append(row(line))
61+
lines.append(row(line)) # noqa: PERF401
6262
if methods:
6363
lines.append(row(""))
6464
lines.append(row("Methods:"))
6565
lines.append(row(""))
66-
for i, method in enumerate(methods):
66+
for _, method in enumerate(methods):
6767
lines.append(row(method))
6868
lines.append(divider)
6969
content = "\n".join(lines)

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# documentation root, use os.path.abspath to make it absolute, like shown here.
2828
sys.path.insert(0, os.path.abspath(".."))
2929

30-
from juju.version import CLIENT_VERSION
30+
from juju.version import CLIENT_VERSION # noqa: E402
3131

3232
version = CLIENT_VERSION
3333

@@ -66,7 +66,7 @@
6666

6767
# General information about the project.
6868
project = "juju"
69-
copyright = "2016, Canonical Ltd."
69+
copyright = "2016, Canonical Ltd." # noqa: A001
7070
author = "Canonical"
7171

7272
# The version info for the project you're documenting, acts as replacement for

examples/add_k8s.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@
2222

2323

2424
async def main():
25-
kubecfg = os.popen("microk8s.config").read()
25+
kubecfg = os.popen("microk8s.config").read() # noqa: S607,S605
2626
cfg = yaml.safe_load(kubecfg)
2727
ctx = {v["name"]: v["context"] for v in cfg["contexts"]}[cfg["current-context"]]
2828
cluster = {v["name"]: v["cluster"] for v in cfg["clusters"]}[ctx["cluster"]]
2929
user = {v["name"]: v["user"] for v in cfg["users"]}[ctx["user"]]
3030

3131
ep = cluster["server"]
32-
caCert = base64.b64decode(cluster["certificate-authority-data"]).decode("utf-8")
32+
ca_cert = base64.b64decode(cluster["certificate-authority-data"]).decode("utf-8")
3333

3434
controller = Controller()
3535
await controller.connect()
3636

3737
cloud = client.Cloud(
3838
auth_types=["userpass"],
39-
ca_certificates=[caCert],
39+
ca_certificates=[ca_cert],
4040
endpoint=ep,
4141
host_cloud_region="microk8s/localhost",
4242
regions=[client.CloudRegion(endpoint=ep, name="localhost")],

examples/add_secrets_backend.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@ async def main():
5959
print(response["results"])
6060

6161
# List the secrets backend
62-
list = await c.list_secret_backends()
62+
result = await c.list_secret_backends()
6363
print("Output from list secret backends")
64-
print(list["results"])
64+
print(result["results"])
6565

6666
# Remove it
6767
await c.remove_secret_backends("examplevault")
6868

6969
# # Finally after removing
70-
list = await c.list_secret_backends()
70+
result = await c.list_secret_backends()
7171
print("Output from list secret backends after removal")
72-
print(list["results"])
72+
print(result["results"])
7373

7474
await m.disconnect()
7575

examples/formatted_status.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ async def main():
3131
)
3232

3333
await jasyncio.sleep(10)
34-
tmp = tempfile.NamedTemporaryFile(delete=False)
34+
tmp = tempfile.NamedTemporaryFile(delete=False) # noqa: SIM115
3535
LOG.info("status dumped to %s", tmp.name)
3636
with open(tmp.name, "w") as f:
37-
for i in range(10):
37+
for _ in range(10):
3838
# Uncomment this line to get the full status
3939
# using the standard output.
4040
# await formatted_status(model, target=sys.stdout)

examples/future.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ async def main():
3535
"nrpe",
3636
)
3737

38-
result, ok = await model.block_until(lambda: model.matches(goal_state), timeout=600)
38+
_result, _ok = await model.block_until(
39+
lambda: model.matches(goal_state), timeout=600
40+
)
3941

4042

4143
if __name__ == "__main__":

examples/livemodel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from juju.model import Model
1414

1515

16-
async def on_model_change(delta, old, new, model):
16+
async def on_model_change(delta, old, new, model): # noqa: RUF029
1717
print(delta.entity, delta.type, delta.data)
1818
print(old)
1919
print(new)

examples/machine_hostname.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env python3
2-
31
# Copyright 2023 Canonical Ltd.
42
# Licensed under the Apache V2, see LICENCE file for details.
53

examples/model.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env python3
2+
13
# Copyright 2023 Canonical Ltd.
24
# Licensed under the Apache V2, see LICENCE file for details.
35

@@ -17,11 +19,11 @@
1719
async def main():
1820
model = Model()
1921

20-
retryCount = 3
21-
for i in range(0, retryCount):
22+
retries = 3
23+
for _ in range(0, retries):
2224
await model.connect_current()
2325
try:
24-
model.applications["foo"].relations
26+
print(model.applications["foo"].relations)
2527
except JujuEntityNotFoundError as e:
2628
print(e.entity_name)
2729
finally:

0 commit comments

Comments
 (0)