Skip to content

Commit 49cc61a

Browse files
james-bruten-mor-sharp
authored andcommitted
try removing fix_ (MetOffice#194)
* try removing fix_ * fix ruff lint issues * update umdp3_fixer * rerun format * output-format
1 parent f4c14dc commit 49cc61a

File tree

23 files changed

+274
-297
lines changed

23 files changed

+274
-297
lines changed

.github/linters/.ruff.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
cache-dir = "/tmp/.ruff_cache"
22
line-length = 88
3+
output-format = "grouped"
34

45
[lint]
56
# Allow unused variables when underscore-prefixed.

.github/workflows/lint.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ jobs:
4242
# Once the codebase is perfectly linted/formatted, switch to validating only changed files
4343
# VALIDATE_ALL_CODEBASE: false # lint and format new or changed files only
4444
FILTER_REGEX_EXCLUDE: (.*[.]conf.py|pull_request_template.md)
45-
FIX_PYTHON_RUFF_FORMAT: true
46-
FIX_PYTHON_RUFF: true
4745
IGNORE_GITIGNORED_FILES: true
4846
VALIDATE_BASH: true
4947
VALIDATE_CHECKOV: true

fcm_bdiff/fcm_bdiff.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class FCMBase:
3939
Note that the version for Git has a small handful of methods, mostly
4040
internal and some propeties. These are kept as close as possible to
4141
version in git_bdiff.py.
42-
42+
4343
Attributes used to navigate the horros of FCM and thus used in this
4444
package are therefore preceded with an '_' and shouldn't be what is
4545
being referred to outwith this class. Nor should the original
@@ -60,7 +60,7 @@ def __init__(self, parent=None, repo=None):
6060
kind of 'discovery' that was necessary for FCM that is hoped to
6161
become outdated with Git.
6262
"""
63-
63+
6464
# use_mirror checks for SOURCE_UM_MIRROR env var, and if set
6565
# redirects the branch to that value and sets retries.
6666
# Otherwise it returns the branch unchanged and retries=0
@@ -88,7 +88,7 @@ def get_branch_name(self):
8888
For now, define it to be the contants of the URL after .*/main/ has been
8989
stripped off. i.e. it will start with trunk/... or branches/...
9090
"""
91-
91+
9292
pattern = rf"{self.get_repository_root()}/main/(.*)$"
9393
match = re.match(pattern, self._branch_url)
9494
if match:
@@ -101,7 +101,7 @@ def run_fcm_command(self, command, max_retries, snooze):
101101
"""
102102
Run an fcm command, optionally retrying on failure.
103103
"""
104-
104+
105105
retries = 0
106106
while True:
107107
result = subprocess.run(
@@ -156,7 +156,7 @@ def get_branch_parent(self):
156156
Given the raw output from an fcm binfo command - which can be retrieved by
157157
calling get_branch_info() - returns the Branch Parent Field
158158
"""
159-
159+
160160
parent = re.search(
161161
r"^Branch Parent:\s*(?P<parent>.*)$",
162162
self._branch_info,
@@ -182,7 +182,7 @@ def get_url(self):
182182
Given the raw output from an fcm binfo command - which can be retrieved
183183
by calling get_branch_info() - returns the URL field
184184
"""
185-
185+
186186
url = re.search(r"^URL:\s*(?P<url>.*)$", self._branch_info, flags=re.MULTILINE)
187187
if url:
188188
url = url.group("url")
@@ -195,7 +195,7 @@ def is_trunk_test(self, url):
195195
Given an FCM url, returns True if it appears to be pointing to the
196196
UM main trunk
197197
"""
198-
198+
199199
search = re.search(
200200
r"""
201201
(svn://fcm\d+/\w+_svn/\w+/trunk|
@@ -212,7 +212,7 @@ def get_repository_root(self):
212212
Given the raw output from an fcm binfo command - which can be retrieved by
213213
calling get_branch_info() - returns the Repository Root field
214214
"""
215-
215+
216216
repos_root = re.search(
217217
r"^Repository Root:\s*(?P<url>.*)\s*$",
218218
self._branch_info,
@@ -229,7 +229,7 @@ def get_latest_commit(self):
229229
Given the raw output from an fcm binfo command - which can be retrieved by
230230
calling get_branch_info() - returns the Last Changed Rev
231231
"""
232-
232+
233233
repos_rev = re.search(
234234
r"^Last Changed Rev:\s*(?P<rev>.*)\s*$",
235235
self._branch_info,
@@ -263,7 +263,7 @@ def has_diverged(self):
263263
Bit vague here, so we're going to check to see if 'parent' had
264264
an '@' in it denoting it's a branch of <something>
265265
"""
266-
266+
267267
match = re.match(r".*@(\d+)$", self.parent)
268268
if match:
269269
return True
@@ -272,7 +272,7 @@ def has_diverged(self):
272272

273273
def files(self):
274274
"""Iterate over files changed on the branch."""
275-
275+
276276
dem_danged_files = self._get_files()
277277
for line in dem_danged_files:
278278
if line != "":
@@ -335,7 +335,7 @@ def get_bdiff_summarize(self, snooze=300, retries=0):
335335
(if the branch is the mirror, allow for a few retries in case
336336
it hasn't picked up the latest commit yet)
337337
"""
338-
338+
339339
command = ["fcm", "bdiff", "--summarize", self._branch]
340340
return self.run_fcm_command(command, retries, snooze)
341341

@@ -352,5 +352,5 @@ def __init__(self, branch_info: str):
352352

353353
def is_main(self) -> bool:
354354
"""Return True if the branch is the main trunk."""
355-
355+
356356
return self.is_trunk_test(self._branch_url)

gh_review_project/cr_deadline.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ def parse_args():
3737
testfile_path = Path(__file__).parent / "test"
3838

3939
parser = argparse.ArgumentParser(
40-
"Changes to the Simulation System projects required at the code"
41-
"review deadline."
40+
"Changes to the Simulation System projects required at the codereview deadline."
4241
)
4342

4443
parser.add_argument("--milestone", help="Milestone being released")
@@ -79,7 +78,6 @@ def parse_args():
7978
def main(
8079
milestone: str, test: bool, capture_project: bool, file: Path, dry: bool
8180
) -> None:
82-
8381
# Get milestone data
8482
if test:
8583
issue_data = ProjectData.from_file(ISSUE_ID, file / "issue.json")

gh_review_project/finish_milestone.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* Remaining open PRs and issues against this milestone
1414
* Closed PRs against this milestone
1515
"""
16+
1617
from pathlib import Path
1718
import argparse
1819
from review_project import ProjectData, REVIEW_ID, ISSUE_ID
@@ -186,7 +187,6 @@ def parse_args():
186187
def main(
187188
milestone: str, test: bool, capture_project: bool, file: Path, dry: bool
188189
) -> None:
189-
190190
# Get milestone data
191191
if test:
192192
review_data = ProjectData.from_file(REVIEW_ID, file / "pr.json")

gh_review_project/review_project.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
Classes and functions for interacting with the Simulation Systems Review Tracker
99
Project.
1010
"""
11+
1112
from __future__ import annotations
1213

1314
import json
@@ -248,7 +249,6 @@ def get_milestone(self, milestone: str, status: str = "all") -> dict:
248249
or (status == "open" and item.status in item.open_states)
249250
or (status == "closed" and item.status not in item.open_states)
250251
):
251-
252252
milestone_data[item.repo].append(item)
253253
return milestone_data
254254

@@ -357,7 +357,7 @@ def modify_milestone(self, milestone: str, dry_run: bool = False) -> None:
357357
if milestone:
358358
command += f" --milestone='{milestone}'"
359359
else:
360-
command += f" --remove-milestone"
360+
command += " --remove-milestone"
361361

362362
message = f"Changing milestone for #{self.number} in {self.repo}"
363363

gh_review_project/workload.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ def parse_args():
202202

203203

204204
def main(total: bool, test: bool, capture_project: bool, file: Path):
205-
206205
# Extract data from github about the reviews and team members.
207206
if test:
208207
data = ProjectData.from_file(REVIEW_ID, file)

kgo_updates/kgo_update/kgo_update.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
3232
3333
"""
34+
3435
import argparse
3536
import os
3637
import re
@@ -208,7 +209,6 @@ def group_comparisons_by_dir(comparisons, skip=False):
208209
"""
209210
kgo_dirs = defaultdict(dict)
210211
for _, kgo_file, suite_file, status, _ in comparisons:
211-
212212
# If the kgo_file isn't set, move on (in some cases the test is not
213213
# comparing two files at all
214214
if kgo_file is None:
@@ -237,17 +237,13 @@ def group_comparisons_by_dir(comparisons, skip=False):
237237
# If the above goes wrong it will eventually hit root; if this happens
238238
# we cannot continue as something is seriously not right
239239
if basedir == "/":
240-
msg = (
241-
"Problem locating KGO directory - "
242-
"is this actually a KGO file?\n {0}"
243-
)
240+
msg = "Problem locating KGO directory - is this actually a KGO file?\n {0}"
244241
sys.exit(msg.format(kgo_file))
245242

246243
# Otherwise add the result to the list - for each entry we store the
247244
# relative path to the KGO file and the full path to the file in the
248245
# suite which should be used to update it (if it needs updating)
249246
if status.strip() in UPDATE_CRITERIA:
250-
251247
# Here we could check if this update has already been lodged,
252248
# and if it has perhaps we can do some additional checking
253249
# (for instance, are the changes in answers the same?)
@@ -501,7 +497,7 @@ def _split_lines(self, text, width):
501497
"-E",
502498
"--extension",
503499
default=".cylc",
504-
help="The extension of the variables file, either .rc " "or .cylc",
500+
help="The extension of the variables file, either .rc or .cylc",
505501
)
506502

507503
args = parser.parse_args()
@@ -607,8 +603,7 @@ def _split_lines(self, text, width):
607603
# Open the file for viewing in user's editor
608604
if interactive:
609605
print(
610-
f"\n\nOpening {script_path}\nHit Return to Step through, "
611-
"q to print all\n\n"
606+
f"\n\nOpening {script_path}\nHit Return to Step through, q to print all\n\n"
612607
)
613608
with open(script_path, "r") as f:
614609
line_count = 0

lfric_macros/files/template_versions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sys
22

3-
from metomi.rose.upgrade import MacroUpgrade
3+
4+
from metomi.rose.upgrade import MacroUpgrade # noqa: F401
45

56

67
class UpgradeError(Exception):
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import os
2-
from shlex import split
3-
from pathlib import Path, PurePath
4-
import networkx as nx
1+
import os # noqa: F401
2+
from shlex import split # noqa: F401
3+
from pathlib import Path, PurePath # noqa: F401
4+
import networkx as nx # noqa: F401

0 commit comments

Comments
 (0)