Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kwk committed May 17, 2024
1 parent 7986547 commit c21ef91
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ repos:
- id: name-tests-test
- id: requirements-txt-fixer

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.2
hooks:
- id: pyupgrade
args:
- "--py311-plus"

# See https://tmt.readthedocs.io/en/latest/guide.html#checking-data-validity
- repo: https://github.com/teemtee/tmt.git
rev: 1.32.2
Expand Down
4 changes: 2 additions & 2 deletions scripts/create-diagrams.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def add_html_header_menu(
all_packages (str]): All the packages names for which to generate a menu entry
plotly_div_id (str, optional): Plotly's HTML div's ID. Defaults to "plotly_div_id".
"""
replace_me = '<div id="{}"'.format(plotly_div_id)
replace_me = f'<div id="{plotly_div_id}"'

file = Path(filepath)
header_menu = '<div id="headermenu">Build-Stats by package: '
Expand Down Expand Up @@ -323,7 +323,7 @@ def main() -> None:
# To debug, uncomment the following:
# fig.show()
# break
filepath = "fig-{}.html".format(package_name)
filepath = f"fig-{package_name}.html"
save_figure(fig=fig, filepath=filepath)
add_html_header_menu(filepath=filepath, all_packages=all_packages)

Expand Down
4 changes: 2 additions & 2 deletions scripts/get-build-stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def gather_build_stats(
def main():
defaut_yyyymmdd = datetime.today().strftime("%Y%m%d")
default_copr_ownername = "@fedora-llvm-team"
default_copr_projectname = "llvm-snapshots-incubator-{}".format(defaut_yyyymmdd)
default_copr_projectname = f"llvm-snapshots-incubator-{defaut_yyyymmdd}"

parser = argparse.ArgumentParser(
description="Print stats for a snapshot run in CVS format for further consumption"
Expand All @@ -81,7 +81,7 @@ def main():
dest="copr_ownername",
type=str,
default=default_copr_ownername,
help="copr ownername to use (default: {})".format(default_copr_ownername),
help=f"copr ownername to use (default: {default_copr_ownername})",
)

parser.add_argument(
Expand Down
6 changes: 3 additions & 3 deletions scripts/get-good-commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_good_commit(
"""
)

required_checks = set((check, "success") for check in required_checks)
required_checks = {(check, "success") for check in required_checks}
for i in range(0, max_tries):
commit = repo.get_commit(sha=next_sha)
commit_url = f"https://github.com/{project}/commit/{commit.sha}"
Expand All @@ -50,9 +50,9 @@ def get_good_commit(
)
# Makes sure the required checks are among the ones that have been run
# on the commit.
actual_checks = set(
actual_checks = {
(status.context, status.state) for status in commit.get_statuses()
)
}
if not required_checks.issubset(actual_checks):
logging.warning(
f"- Ignoring commit because of missing or failed check(s): {required_checks - actual_checks}"
Expand Down
8 changes: 4 additions & 4 deletions scripts/upload-source-snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ def main(args) -> None:
yyyymmdd = args.yyyymmdd
release_name = args.release_name
tag_name = release_name
print("uploading assets for yyyymmdd='{}'".format(yyyymmdd))
print(f"uploading assets for yyyymmdd='{yyyymmdd}'")
try:
release = repo.get_release(release_name)
except UnknownObjectException as ex:
print("release '{}' not found but creating it now".format(release_name))
print(f"release '{release_name}' not found but creating it now")
release = repo.create_git_release(
prerelease=True,
name=release_name,
Expand All @@ -29,7 +29,7 @@ def main(args) -> None:
)
else:
dir = os.getenv(key="GITHUB_WORKSPACE", default=".")
print("looking for source snapshots in directory: {}".format(dir))
print(f"looking for source snapshots in directory: {dir}")
glob_patterns = [
"*-{}.src.tar.xz",
"llvm-release-{}.txt",
Expand All @@ -39,7 +39,7 @@ def main(args) -> None:
for pattern in glob_patterns:
for name in glob(pattern.format(yyyymmdd)):
path = os.path.join(dir, name)
print("uploading path: {}".format(path))
print(f"uploading path: {path}")
release.upload_asset(path=path)


Expand Down
8 changes: 3 additions & 5 deletions snapshot_manager/snapshot_manager/github_graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def encoding(self) -> str:
return self.__encoding

def run_from_file(
self, filename: str, variables: dict[str, Union[str, int]] = None, **kwargs
self, filename: str, variables: dict[str, str | int] = None, **kwargs
) -> Any:
"""
Read the query/mutation from the given file and execute it with the variables
Expand All @@ -84,7 +84,7 @@ def run_from_file(
variables (dict): The variables to be applied to the query/mutation.
**kwargs: key-value pairs (e.g. {raise_on_error=True})
"""
with open(file=filename, mode="r", encoding=self.encoding) as file_handle:
with open(file=filename, encoding=self.encoding) as file_handle:
query = file_handle.read()
return self.run(query, variables, **kwargs)

Expand All @@ -103,9 +103,7 @@ def close(self):
"""Closes the session."""
self.__session.close()

def run(
self, query: str, variables: dict[str, Union[str, int]] = None, **kwargs
) -> dict:
def run(self, query: str, variables: dict[str, str | int] = None, **kwargs) -> dict:
"""
Execute the query with the variables applied. If not requested otherwise
the plain result is returned. If you want to raise an exception in case
Expand Down

0 comments on commit c21ef91

Please sign in to comment.