Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/linters/.ruff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cache-dir = "/tmp/.ruff_cache"
line-length = 88
output-format = "grouped"

[lint]
# Allow unused variables when underscore-prefixed.
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ jobs:
# Once the codebase is perfectly linted/formatted, switch to validating only changed files
# VALIDATE_ALL_CODEBASE: false # lint and format new or changed files only
FILTER_REGEX_EXCLUDE: (.*[.]conf.py|pull_request_template.md)
FIX_PYTHON_RUFF_FORMAT: true
FIX_PYTHON_RUFF: true
IGNORE_GITIGNORED_FILES: true
VALIDATE_BASH: true
VALIDATE_CHECKOV: true
Expand Down
26 changes: 13 additions & 13 deletions fcm_bdiff/fcm_bdiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class FCMBase:
Note that the version for Git has a small handful of methods, mostly
internal and some propeties. These are kept as close as possible to
version in git_bdiff.py.

Attributes used to navigate the horros of FCM and thus used in this
package are therefore preceded with an '_' and shouldn't be what is
being referred to outwith this class. Nor should the original
Expand All @@ -60,7 +60,7 @@ def __init__(self, parent=None, repo=None):
kind of 'discovery' that was necessary for FCM that is hoped to
become outdated with Git.
"""

# use_mirror checks for SOURCE_UM_MIRROR env var, and if set
# redirects the branch to that value and sets retries.
# Otherwise it returns the branch unchanged and retries=0
Expand Down Expand Up @@ -88,7 +88,7 @@ def get_branch_name(self):
For now, define it to be the contants of the URL after .*/main/ has been
stripped off. i.e. it will start with trunk/... or branches/...
"""

pattern = rf"{self.get_repository_root()}/main/(.*)$"
match = re.match(pattern, self._branch_url)
if match:
Expand All @@ -101,7 +101,7 @@ def run_fcm_command(self, command, max_retries, snooze):
"""
Run an fcm command, optionally retrying on failure.
"""

retries = 0
while True:
result = subprocess.run(
Expand Down Expand Up @@ -156,7 +156,7 @@ def get_branch_parent(self):
Given the raw output from an fcm binfo command - which can be retrieved by
calling get_branch_info() - returns the Branch Parent Field
"""

parent = re.search(
r"^Branch Parent:\s*(?P<parent>.*)$",
self._branch_info,
Expand All @@ -182,7 +182,7 @@ def get_url(self):
Given the raw output from an fcm binfo command - which can be retrieved
by calling get_branch_info() - returns the URL field
"""

url = re.search(r"^URL:\s*(?P<url>.*)$", self._branch_info, flags=re.MULTILINE)
if url:
url = url.group("url")
Expand All @@ -195,7 +195,7 @@ def is_trunk_test(self, url):
Given an FCM url, returns True if it appears to be pointing to the
UM main trunk
"""

search = re.search(
r"""
(svn://fcm\d+/\w+_svn/\w+/trunk|
Expand All @@ -212,7 +212,7 @@ def get_repository_root(self):
Given the raw output from an fcm binfo command - which can be retrieved by
calling get_branch_info() - returns the Repository Root field
"""

repos_root = re.search(
r"^Repository Root:\s*(?P<url>.*)\s*$",
self._branch_info,
Expand All @@ -229,7 +229,7 @@ def get_latest_commit(self):
Given the raw output from an fcm binfo command - which can be retrieved by
calling get_branch_info() - returns the Last Changed Rev
"""

repos_rev = re.search(
r"^Last Changed Rev:\s*(?P<rev>.*)\s*$",
self._branch_info,
Expand Down Expand Up @@ -263,7 +263,7 @@ def has_diverged(self):
Bit vague here, so we're going to check to see if 'parent' had
an '@' in it denoting it's a branch of <something>
"""

match = re.match(r".*@(\d+)$", self.parent)
if match:
return True
Expand All @@ -272,7 +272,7 @@ def has_diverged(self):

def files(self):
"""Iterate over files changed on the branch."""

dem_danged_files = self._get_files()
for line in dem_danged_files:
if line != "":
Expand Down Expand Up @@ -335,7 +335,7 @@ def get_bdiff_summarize(self, snooze=300, retries=0):
(if the branch is the mirror, allow for a few retries in case
it hasn't picked up the latest commit yet)
"""

command = ["fcm", "bdiff", "--summarize", self._branch]
return self.run_fcm_command(command, retries, snooze)

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

def is_main(self) -> bool:
"""Return True if the branch is the main trunk."""

return self.is_trunk_test(self._branch_url)
4 changes: 1 addition & 3 deletions gh_review_project/cr_deadline.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ def parse_args():
testfile_path = Path(__file__).parent / "test"

parser = argparse.ArgumentParser(
"Changes to the Simulation System projects required at the code"
"review deadline."
"Changes to the Simulation System projects required at the codereview deadline."
)

parser.add_argument("--milestone", help="Milestone being released")
Expand Down Expand Up @@ -79,7 +78,6 @@ def parse_args():
def main(
milestone: str, test: bool, capture_project: bool, file: Path, dry: bool
) -> None:

# Get milestone data
if test:
issue_data = ProjectData.from_file(ISSUE_ID, file / "issue.json")
Expand Down
2 changes: 1 addition & 1 deletion gh_review_project/finish_milestone.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* Remaining open PRs and issues against this milestone
* Closed PRs against this milestone
"""

from pathlib import Path
import argparse
from review_project import ProjectData, REVIEW_ID, ISSUE_ID
Expand Down Expand Up @@ -186,7 +187,6 @@ def parse_args():
def main(
milestone: str, test: bool, capture_project: bool, file: Path, dry: bool
) -> None:

# Get milestone data
if test:
review_data = ProjectData.from_file(REVIEW_ID, file / "pr.json")
Expand Down
4 changes: 2 additions & 2 deletions gh_review_project/review_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Classes and functions for interacting with the Simulation Systems Review Tracker
Project.
"""

from __future__ import annotations

import json
Expand Down Expand Up @@ -248,7 +249,6 @@ def get_milestone(self, milestone: str, status: str = "all") -> dict:
or (status == "open" and item.status in item.open_states)
or (status == "closed" and item.status not in item.open_states)
):

milestone_data[item.repo].append(item)
return milestone_data

Expand Down Expand Up @@ -357,7 +357,7 @@ def modify_milestone(self, milestone: str, dry_run: bool = False) -> None:
if milestone:
command += f" --milestone='{milestone}'"
else:
command += f" --remove-milestone"
command += " --remove-milestone"

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

Expand Down
1 change: 0 additions & 1 deletion gh_review_project/workload.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ def parse_args():


def main(total: bool, test: bool, capture_project: bool, file: Path):

# Extract data from github about the reviews and team members.
if test:
data = ProjectData.from_file(REVIEW_ID, file)
Expand Down
13 changes: 4 additions & 9 deletions kgo_updates/kgo_update/kgo_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"""

import argparse
import os
import re
Expand Down Expand Up @@ -208,7 +209,6 @@ def group_comparisons_by_dir(comparisons, skip=False):
"""
kgo_dirs = defaultdict(dict)
for _, kgo_file, suite_file, status, _ in comparisons:

# If the kgo_file isn't set, move on (in some cases the test is not
# comparing two files at all
if kgo_file is None:
Expand Down Expand Up @@ -237,17 +237,13 @@ def group_comparisons_by_dir(comparisons, skip=False):
# If the above goes wrong it will eventually hit root; if this happens
# we cannot continue as something is seriously not right
if basedir == "/":
msg = (
"Problem locating KGO directory - "
"is this actually a KGO file?\n {0}"
)
msg = "Problem locating KGO directory - is this actually a KGO file?\n {0}"
sys.exit(msg.format(kgo_file))

# Otherwise add the result to the list - for each entry we store the
# relative path to the KGO file and the full path to the file in the
# suite which should be used to update it (if it needs updating)
if status.strip() in UPDATE_CRITERIA:

# Here we could check if this update has already been lodged,
# and if it has perhaps we can do some additional checking
# (for instance, are the changes in answers the same?)
Expand Down Expand Up @@ -501,7 +497,7 @@ def _split_lines(self, text, width):
"-E",
"--extension",
default=".cylc",
help="The extension of the variables file, either .rc " "or .cylc",
help="The extension of the variables file, either .rc or .cylc",
)

args = parser.parse_args()
Expand Down Expand Up @@ -607,8 +603,7 @@ def _split_lines(self, text, width):
# Open the file for viewing in user's editor
if interactive:
print(
f"\n\nOpening {script_path}\nHit Return to Step through, "
"q to print all\n\n"
f"\n\nOpening {script_path}\nHit Return to Step through, q to print all\n\n"
)
with open(script_path, "r") as f:
line_count = 0
Expand Down
3 changes: 2 additions & 1 deletion lfric_macros/files/template_versions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys

from metomi.rose.upgrade import MacroUpgrade

from metomi.rose.upgrade import MacroUpgrade # noqa: F401


class UpgradeError(Exception):
Expand Down
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we eliminate the #noqa clutter by adding this to the bottom of the file? Probably require an __init__.py if not present already

__all__ = ["Path", "PurePath", "split", "nx", "os"]

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os
from shlex import split
from pathlib import Path, PurePath
import networkx as nx
import os # noqa: F401
from shlex import split # noqa: F401
from pathlib import Path, PurePath # noqa: F401
import networkx as nx # noqa: F401
1 change: 1 addition & 0 deletions lfric_styling/styling_keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""
Newer keywords used during physics forking.
"""

NEW_KEYWORDS = [
"abort",
"abs",
Expand Down
5 changes: 2 additions & 3 deletions script_copyright_checker/bin/copyright_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Script which tests code files within the UM repository to ensure they contain a
recognised copyright notice.
"""

import argparse
import os
import re
Expand Down Expand Up @@ -208,9 +209,7 @@ def parse_options():
"--full_trunk",
action="store_true",
default=False,
help=(
"run on use the full file list when trunk, " "else run on fcm branch-diff"
),
help=("run on use the full file list when trunk, else run on fcm branch-diff"),
)
excl_group.add_argument(
"files",
Expand Down
Loading