diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e63d55f..ede0787 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/scripts/create-diagrams.py b/scripts/create-diagrams.py index 4420504..e8cafe2 100755 --- a/scripts/create-diagrams.py +++ b/scripts/create-diagrams.py @@ -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 = '
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) diff --git a/scripts/get-build-stats.py b/scripts/get-build-stats.py index 1d6d112..d424a4e 100755 --- a/scripts/get-build-stats.py +++ b/scripts/get-build-stats.py @@ -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" @@ -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( diff --git a/scripts/get-good-commit.py b/scripts/get-good-commit.py index ad1557c..82d4cfa 100755 --- a/scripts/get-good-commit.py +++ b/scripts/get-good-commit.py @@ -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}" @@ -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}" diff --git a/scripts/upload-source-snapshots.py b/scripts/upload-source-snapshots.py index ac211a2..b55f450 100755 --- a/scripts/upload-source-snapshots.py +++ b/scripts/upload-source-snapshots.py @@ -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, @@ -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", @@ -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) diff --git a/snapshot_manager/snapshot_manager/github_graphql.py b/snapshot_manager/snapshot_manager/github_graphql.py index bfcc310..a303eed 100644 --- a/snapshot_manager/snapshot_manager/github_graphql.py +++ b/snapshot_manager/snapshot_manager/github_graphql.py @@ -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 @@ -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) @@ -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