Skip to content

Commit 3c91283

Browse files
Merge pull request #5 from ISISComputingGroup/ruff
Ruff
2 parents 8ac9f6b + 83e6471 commit 3c91283

File tree

8 files changed

+50
-29
lines changed

8 files changed

+50
-29
lines changed

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eb211431b3d7ebf3d61bc2f1f79f52e137003943
2+
2c039635bbef50f058e9d05cb863104f8dd56509

.github/workflows/linters.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: Linter
2+
on: [pull_request]
3+
jobs:
4+
call-workflow:
5+
uses: ISISComputingGroup/reusable-workflows/.github/workflows/linters.yml@main
6+
with:
7+
compare-branch: origin/master

hotfix_checker.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
print(f"INFO: REPO_DIR: {os.environ['REPO_DIR']}")
1919
print(f"INFO: UPSTREAM_BRANCH: {os.environ['UPSTREAM_BRANCH_CONFIG']}")
2020
print(f"INFO: ARTEFACT_DIR: {os.environ['WORKSPACE']}")
21-
print(
22-
f"INFO: USE_TEST_INSTRUMENT_LIST: {os.environ['USE_TEST_INSTRUMENT_LIST']}"
23-
)
21+
print(f"INFO: USE_TEST_INSTRUMENT_LIST: {os.environ['USE_TEST_INSTRUMENT_LIST']}")
2422
print(f"INFO: TEST_INSTRUMENT_LIST: {os.environ['TEST_INSTRUMENT_LIST']}")
2523
print(f"INFO: DEBUG_MODE: {os.environ['DEBUG_MODE']}")
2624

utils/communication_utils/channel_access.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from enum import (
1010
Enum,
1111
)
12-
from typing import Dict, Any
12+
from typing import Any, Dict
1313

1414
from genie_python.channel_access_exceptions import (
1515
ReadAccessException,
@@ -36,7 +36,7 @@ def __init__(
3636
def get_value(
3737
self,
3838
pv,
39-
) -> str | dict | None:
39+
) -> str | dict | None:
4040
"""Gets the value of the PV. Returns None if PV is unavailable.
4141
:return: The PV value as a string, or None if there was an error.
4242
"""
@@ -72,9 +72,7 @@ def get_inst_list(
7272
:return: a list of strings of instrument names.
7373
"""
7474
pv_value = self.get_value("CS:INSTLIST")
75-
return (
76-
{} if pv_value is None else json.loads(self._dehex_and_decompress(pv_value))
77-
)
75+
return {} if pv_value is None else json.loads(self._dehex_and_decompress(pv_value))
7876

7977

8078
class PvInterestingLevel(Enum):

utils/communication_utils/ssh_access.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""This module provides utilities for SSH access."""
2+
23
from typing import Dict
34

45
import paramiko

utils/hotfix_utils/InstrumentChecker.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def split_git_log(self, git_log: str, prefix: str) -> dict:
207207
if prefix is None or message.startswith(prefix):
208208
commit_dict[hash] = message
209209
return commit_dict
210-
210+
211211
def check_instrument(self) -> dict:
212212
"""Check if there are any hotfixes or uncommitted changes on AN instrument.
213213
@@ -257,7 +257,9 @@ def check_instrument(self) -> dict:
257257
)
258258

259259
# Check if any uncommitted changes are on the instrument
260-
self.uncommitted_changes_enum, self.uncommitted_changes_messages = self.check_for_uncommitted_changes()
260+
self.uncommitted_changes_enum, self.uncommitted_changes_messages = (
261+
self.check_for_uncommitted_changes()
262+
)
261263

262264
def as_string(self) -> str:
263265
"""Return the Instrument object as a string.

utils/hotfix_utils/RepoChecker.py

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import sys
55

66
import requests
7-
from packaging.version import Version, InvalidVersion
7+
from packaging.version import InvalidVersion, Version
88

99
from utils.hotfix_utils.InstrumentChecker import InstrumentChecker
1010

@@ -67,15 +67,15 @@ def get_insts_on_latest_ibex_via_inst_config(self) -> list:
6767

6868
latest_major_version = versions[-1].major
6969
second_latest_major_version = latest_major_version - 1
70-
print(f"INFO: checking versions {latest_major_version}.x.x and {second_latest_major_version}.x.x")
70+
print(
71+
f"INFO: checking versions {latest_major_version}.x.x and {second_latest_major_version}.x.x"
72+
)
7173

7274
# filter out the instruments that are not on the latest version
7375
insts_on_latest_ibex = [
7476
inst["hostname"]
7577
for inst in result_list
76-
if (
77-
inst["version"].major in [latest_major_version, second_latest_major_version]
78-
)
78+
if (inst["version"].major in [latest_major_version, second_latest_major_version])
7979
]
8080

8181
return insts_on_latest_ibex
@@ -105,11 +105,10 @@ def check_instruments(self) -> None:
105105

106106
def update_instrument_status_lists(instrument, status_list_key, messages=None):
107107
if messages:
108-
instrument_status_lists[status_list_key].append({instrument.hostname : messages})
108+
instrument_status_lists[status_list_key].append({instrument.hostname: messages})
109109
else:
110110
instrument_status_lists[status_list_key].append(instrument.hostname)
111111

112-
113112
for hostname in instrument_list:
114113
instrument = InstrumentChecker(hostname)
115114
try:
@@ -119,17 +118,34 @@ def update_instrument_status_lists(instrument, status_list_key, messages=None):
119118
print(instrument.as_string())
120119

121120
if instrument.commits_local_not_on_upstream_enum == CHECK.TRUE:
122-
update_instrument_status_lists(instrument, self._commits_on_local_not_upstream_key, instrument.commits_local_not_on_upstream_messages)
123-
121+
update_instrument_status_lists(
122+
instrument,
123+
self._commits_on_local_not_upstream_key,
124+
instrument.commits_local_not_on_upstream_messages,
125+
)
126+
124127
if instrument.uncommitted_changes_enum == CHECK.TRUE:
125-
update_instrument_status_lists(instrument, self._uncommitted_changes_key, instrument.uncommitted_changes_messages)
126-
128+
update_instrument_status_lists(
129+
instrument,
130+
self._uncommitted_changes_key,
131+
instrument.uncommitted_changes_messages,
132+
)
127133

128134
if instrument.commits_upstream_not_on_local_enum == CHECK.TRUE:
129-
update_instrument_status_lists(instrument, self._commits_on_upstream_not_local_key, instrument.commits_upstream_not_on_local_messages)
135+
update_instrument_status_lists(
136+
instrument,
137+
self._commits_on_upstream_not_local_key,
138+
instrument.commits_upstream_not_on_local_messages,
139+
)
130140

131-
if instrument.commits_local_not_on_upstream_enum == CHECK.UNDETERMINABLE or instrument.uncommitted_changes_enum == CHECK.UNDETERMINABLE or instrument.commits_upstream_not_on_local_enum == CHECK.UNDETERMINABLE:
132-
update_instrument_status_lists(instrument, self._undeterminable_at_some_point_key)
141+
if (
142+
instrument.commits_local_not_on_upstream_enum == CHECK.UNDETERMINABLE
143+
or instrument.uncommitted_changes_enum == CHECK.UNDETERMINABLE
144+
or instrument.commits_upstream_not_on_local_enum == CHECK.UNDETERMINABLE
145+
):
146+
update_instrument_status_lists(
147+
instrument, self._undeterminable_at_some_point_key
148+
)
133149

134150
except Exception as e:
135151
print(f"ERROR: Could not connect to {instrument.hostname} ({str(e)})")
@@ -140,8 +156,7 @@ def update_instrument_status_lists(instrument, status_list_key, messages=None):
140156
(self._commits_on_local_not_upstream_key, "Commits on local not upstream"),
141157
(self._commits_on_upstream_not_local_key, "Commits on upstream not on local"),
142158
(self._undeterminable_at_some_point_key, "Undeterminable at some point"),
143-
]
144-
159+
]
145160

146161
print("INFO: Summary of results")
147162
for key, prefix in keys_and_prefixes:

utils/jenkins_utils/jenkins_utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ def save_git_status(
2424
2525
"""
2626
# log the output to a workspace file for viewing later
27-
if not os.path.exists(
28-
os.path.join(artefact_dir, "git_status")
29-
):
27+
if not os.path.exists(os.path.join(artefact_dir, "git_status")):
3028
os.makedirs(os.path.join(artefact_dir, "git_status"))
3129

3230
with open(

0 commit comments

Comments
 (0)