From ff07a09d8910e984fc24c054e7aae3eb4e27bfcf Mon Sep 17 00:00:00 2001 From: Pedro Brochado Date: Thu, 21 Mar 2024 09:16:53 -0300 Subject: [PATCH] More re-formatting Re-triggering [noissue] --- .bumpversion.cfg | 2 +- .ci/scripts/check_release.py | 12 ++------ .ci/scripts/check_requirements.py | 20 ++++--------- .ci/scripts/collect_changes.py | 12 ++------ .ci/scripts/validate_commit_message.py | 10 ++----- .github/workflows/scripts/docs-publisher.py | 8 ++---- .../stage-changelog-for-default-branch.py | 4 +-- .../scripts/update_backport_labels.py | 8 ++---- pyproject.toml | 1 + src/pulp_docs/mkdocs_macros.py | 20 ++++--------- src/pulp_docs/navigation.py | 28 ++++--------------- src/pulp_docs/repository.py | 12 +++----- src/pulp_docs/utils/aggregation.py | 8 ++---- 13 files changed, 36 insertions(+), 109 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index aad52c4..4ffdb7f 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.1.0a1.dev +current_version = 0.1.0 commit = False tag = False parse = (?P\d+)\.(?P\d+)\.(0a)?(?P\d+)(\.(?P[a-z]+))? diff --git a/.ci/scripts/check_release.py b/.ci/scripts/check_release.py index 217fff2..ae29b42 100755 --- a/.ci/scripts/check_release.py +++ b/.ci/scripts/check_release.py @@ -64,9 +64,7 @@ def main(): for branch in branches: if branch != DEFAULT_BRANCH: # Check if a Z release is needed - changes = repo.git.ls_tree( - "-r", "--name-only", f"origin/{branch}", "CHANGES/" - ) + changes = repo.git.ls_tree("-r", "--name-only", f"origin/{branch}", "CHANGES/") z_release = False for change in changes.split("\n"): # Check each changelog file to make sure everything checks out @@ -103,9 +101,7 @@ def main(): "--", ".bumpversion.cfg", ) - next_version = ( - bump_commit.split("to ")[-1] if bump_commit else None - ) + next_version = bump_commit.split("to ")[-1] if bump_commit else None # You could, theoretically, be next_vers==None here - but that's always # been true for this script. @@ -117,9 +113,7 @@ def main(): releases.append(next_version) else: # Check if a Y release is needed - changes = repo.git.ls_tree( - "-r", "--name-only", DEFAULT_BRANCH, "CHANGES/" - ) + changes = repo.git.ls_tree("-r", "--name-only", DEFAULT_BRANCH, "CHANGES/") for change in changes.split("\n"): _, ext = os.path.splitext(change) if ext in Y_CHANGELOG_EXTS: diff --git a/.ci/scripts/check_requirements.py b/.ci/scripts/check_requirements.py index a50b84c..6a1eedd 100755 --- a/.ci/scripts/check_requirements.py +++ b/.ci/scripts/check_requirements.py @@ -35,14 +35,10 @@ if line.startswith("git+"): # The single exception... if "pulp-smash" not in line: - errors.append( - f"{filename}:{nr}: Invalid source requirement: {line}" - ) + errors.append(f"{filename}:{nr}: Invalid source requirement: {line}") elif line.startswith("-r "): if check_r: - errors.append( - f"{filename}:{nr}: Invalid deferred requirement: {line}" - ) + errors.append(f"{filename}:{nr}: Invalid deferred requirement: {line}") else: errors.append(f"{filename}:{nr}: Unreadable requirement {line}") else: @@ -52,20 +48,14 @@ not req.name.startswith("opentelemetry") and req.name != "pulp-docs-client" ): - errors.append( - f"{filename}:{nr}: Prerelease versions found in {line}." - ) + errors.append(f"{filename}:{nr}: Prerelease versions found in {line}.") ops = [op for op, ver in req.specs] spec = str(req.specs) if "~=" in ops: - warnings.warn( - f"{filename}:{nr}: Please avoid using ~= on {req.name}!" - ) + warnings.warn(f"{filename}:{nr}: Please avoid using ~= on {req.name}!") elif "<" not in ops and "<=" not in ops and "==" not in ops: if check_upperbound: - errors.append( - f"{filename}:{nr}: Upper bound missing in {line}." - ) + errors.append(f"{filename}:{nr}: Upper bound missing in {line}.") except FileNotFoundError: # skip this test for plugins that don't use this requirements.txt pass diff --git a/.ci/scripts/collect_changes.py b/.ci/scripts/collect_changes.py index e9a5b94..3409770 100755 --- a/.ci/scripts/collect_changes.py +++ b/.ci/scripts/collect_changes.py @@ -34,9 +34,7 @@ TITLE_REGEX = ( "(" + re.escape( - TITLE_FORMAT.format( - name="NAME_REGEX", version="VERSION_REGEX", project_date="DATE_REGEX" - ) + TITLE_FORMAT.format(name="NAME_REGEX", version="VERSION_REGEX", project_date="DATE_REGEX") ) .replace("NAME_REGEX", NAME_REGEX) .replace("VERSION_REGEX", VERSION_REGEX) @@ -60,17 +58,13 @@ def _tokenize_changes(splits): def split_changelog(changelog): preamble, rest = changelog.split(START_STRING, maxsplit=1) split_rest = re.split(TITLE_REGEX, rest) - return preamble + START_STRING + split_rest[0], list( - _tokenize_changes(split_rest[1:]) - ) + return preamble + START_STRING + split_rest[0], list(_tokenize_changes(split_rest[1:])) def main(): repo = Repo(os.getcwd()) remote = repo.remotes[0] - branches = [ - ref for ref in remote.refs if re.match(r"^([0-9]+)\.([0-9]+)$", ref.remote_head) - ] + branches = [ref for ref in remote.refs if re.match(r"^([0-9]+)\.([0-9]+)$", ref.remote_head)] branches.sort(key=lambda ref: parse_version(ref.remote_head), reverse=True) branches = [ref.name for ref in branches] diff --git a/.ci/scripts/validate_commit_message.py b/.ci/scripts/validate_commit_message.py index eab6a76..6af545a 100755 --- a/.ci/scripts/validate_commit_message.py +++ b/.ci/scripts/validate_commit_message.py @@ -19,9 +19,7 @@ NO_ISSUE = "[noissue]" CHANGELOG_EXTS = [".feature", ".bugfix", ".doc", ".removal", ".misc", ".deprecation"] sha = sys.argv[1] -message = subprocess.check_output(["git", "log", "--format=%B", "-n 1", sha]).decode( - "utf-8" -) +message = subprocess.check_output(["git", "log", "--format=%B", "-n 1", sha]).decode("utf-8") KEYWORDS = ["fixes", "closes"] @@ -68,11 +66,7 @@ def __check_changelog(issue): __check_changelog(issue) else: if NO_ISSUE in message: - print( - "Commit {sha} has no issues but is tagged {tag}.".format( - sha=sha[0:7], tag=NO_ISSUE - ) - ) + print("Commit {sha} has no issues but is tagged {tag}.".format(sha=sha[0:7], tag=NO_ISSUE)) elif "Merge" in message and "cherry picked from commit" in message: pass else: diff --git a/.github/workflows/scripts/docs-publisher.py b/.github/workflows/scripts/docs-publisher.py index 2ec68a2..00e784e 100755 --- a/.github/workflows/scripts/docs-publisher.py +++ b/.github/workflows/scripts/docs-publisher.py @@ -112,9 +112,7 @@ def main(): if exit_code != 0: raise RuntimeError("An error occurred while pushing docs.") elif build_type == "tag": - if (not re.search("[a-zA-Z]", branch) or "post" in branch) and len( - branch.split(".") - ) > 2: + if (not re.search("[a-zA-Z]", branch) or "post" in branch) and len(branch.split(".")) > 2: # Only publish docs at the root if this is the latest version r = requests.get("https://pypi.org/pypi/pulp-docs/json") latest_version = version.parse(json.loads(r.text)["info"]["version"]) @@ -133,9 +131,7 @@ def main(): # publish to the root of docs.pulpproject.org if publish_at_root: version_components = branch.split(".") - x_y_version = "{}.{}".format( - version_components[0], version_components[1] - ) + x_y_version = "{}.{}".format(version_components[0], version_components[1]) remote_path_arg = "%s@%s:%s" % (USERNAME, HOSTNAME, SITE_ROOT) rsync_command = [ "rsync", diff --git a/.github/workflows/scripts/stage-changelog-for-default-branch.py b/.github/workflows/scripts/stage-changelog-for-default-branch.py index 31dea53..97254e1 100755 --- a/.github/workflows/scripts/stage-changelog-for-default-branch.py +++ b/.github/workflows/scripts/stage-changelog-for-default-branch.py @@ -23,9 +23,7 @@ """ ) -parser = argparse.ArgumentParser( - formatter_class=argparse.RawTextHelpFormatter, description=helper -) +parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter, description=helper) parser.add_argument( "release_version", diff --git a/.github/workflows/scripts/update_backport_labels.py b/.github/workflows/scripts/update_backport_labels.py index 845a3f5..01fa835 100755 --- a/.github/workflows/scripts/update_backport_labels.py +++ b/.github/workflows/scripts/update_backport_labels.py @@ -28,13 +28,9 @@ def random_color(): session.headers.update(headers) # get all labels from the repository's current state -response = session.get( - "https://api.github.com/repos/pulp/pulp-docs/labels", headers=headers -) +response = session.get("https://api.github.com/repos/pulp/pulp-docs/labels", headers=headers) assert response.status_code == 200 -old_labels = set( - [x["name"] for x in response.json() if x["name"].startswith("backport-")] -) +old_labels = set([x["name"] for x in response.json() if x["name"].startswith("backport-")]) # get list of branches from template_config.yml with open("./template_config.yml", "r") as f: diff --git a/pyproject.toml b/pyproject.toml index 0260ff7..96ccaf1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,6 +76,7 @@ exclude = ''' \.eggs | \.git | \.venv + | venv | _build | build | dist diff --git a/src/pulp_docs/mkdocs_macros.py b/src/pulp_docs/mkdocs_macros.py index 3d698a9..3364c57 100644 --- a/src/pulp_docs/mkdocs_macros.py +++ b/src/pulp_docs/mkdocs_macros.py @@ -228,9 +228,7 @@ def print_user_repo(repos: Repos, config: Config): ) if len(local_checkouts) == 0: - warn_msgs.append( - "[pulp-docs] No local checkouts found. Serving in read-only mode." - ) + warn_msgs.append("[pulp-docs] No local checkouts found. Serving in read-only mode.") if config.verbose: report = { @@ -263,9 +261,7 @@ def define_env(env): repos = Repos.from_yaml(config.repolist) repos.update_local_checkouts() else: - repos = ( - Repos.test_fixtures() - ) # try to use fixtures if there is no BASE_REPOLIST + repos = Repos.test_fixtures() # try to use fixtures if there is no BASE_REPOLIST log.info(f"Repository configurations loaded: {[repo.name for repo in repos.all]}") # Download and organize repository files @@ -279,18 +275,14 @@ def define_env(env): for repo_or_package in repos.all: # Handle subpackages or repos if isinstance(repo_or_package, SubPackage): - repo_or_package_path = ( - repo_or_package.subpackage_of + "/" + repo_or_package.name - ) + repo_or_package_path = repo_or_package.subpackage_of + "/" + repo_or_package.name else: repo_or_package_path = repo_or_package.name # Add to mkdocstring pythonpath code_sources.append(str(source_dir / repo_or_package_path)) - env.conf["plugins"]["mkdocstrings"].config["handlers"]["python"][ - "paths" - ] = code_sources + env.conf["plugins"]["mkdocstrings"].config["handlers"]["python"]["paths"] = code_sources # Configure navigation log.info("[pulp-docs] Configuring navigation") @@ -307,9 +299,7 @@ def define_env(env): def get_repos(repo_type="content"): "Return repo names by type" _repo_type = [repo_type] if repo_type else None - repos_list = sorted( - repos.get_repos(repo_types=_repo_type), key=lambda x: x.title - ) + repos_list = sorted(repos.get_repos(repo_types=_repo_type), key=lambda x: x.title) repos_data = [ { "title": repo.title, diff --git a/src/pulp_docs/navigation.py b/src/pulp_docs/navigation.py index bebc2fc..ea3c9ea 100644 --- a/src/pulp_docs/navigation.py +++ b/src/pulp_docs/navigation.py @@ -69,11 +69,7 @@ def grouped_by_persona(tmpdir: Path, repos: Repos): f.section(Names.GUIDES, f.get_children, "pulpcore/docs/user/guides"), ] }, - { - "Plugins": f.repo_grouping( - "{repo}/docs/user/{content}", repo_types=["content"] - ) - }, + {"Plugins": f.repo_grouping("{repo}/docs/user/{content}", repo_types=["content"])}, {"Extras": f.repo_grouping("{repo}/docs/user/{content}", repo_types=["other"])}, ] admin_section = [ @@ -117,35 +113,21 @@ def grouped_by_persona(tmpdir: Path, repos: Repos): f.section(Names.GUIDES, f.get_children, "pulpcore/docs/dev/guides"), ] }, - { - "Plugins": f.repo_grouping( - "{repo}/docs/dev/{content}", repo_types=["content"] - ) - }, + {"Plugins": f.repo_grouping("{repo}/docs/dev/{content}", repo_types=["content"])}, {"Extras": f.repo_grouping("{repo}/docs/dev/{content}", repo_types=["other"])}, ] help_section = [ *f.get_children("pulp-docs/docs/sections/help/community"), - { - "Documentation Usage": f.get_children( - "pulp-docs/docs/sections/help/using-this-doc" - ) - }, + {"Documentation Usage": f.get_children("pulp-docs/docs/sections/help/using-this-doc")}, { "Changelogs": [ {"Pulpcore": "pulpcore/changes/changelog.md"}, { "Plugins": sorted( - f.repo_grouping( - "{repo}/changes", repo_types=["content"] - ).items() - ) - }, - { - "Extra": sorted( - f.repo_grouping("{repo}/changes", repo_types=["other"]).items() + f.repo_grouping("{repo}/changes", repo_types=["content"]).items() ) }, + {"Extra": sorted(f.repo_grouping("{repo}/changes", repo_types=["other"]).items())}, ] }, {"Governance": f.get_children("pulp-docs/docs/sections/help/governance")}, diff --git a/src/pulp_docs/repository.py b/src/pulp_docs/repository.py index fb55b2c..57e801b 100644 --- a/src/pulp_docs/repository.py +++ b/src/pulp_docs/repository.py @@ -143,9 +143,7 @@ def download_from_gh_main(dest_dir: Path, owner: str, name: str, branch: str): try: subprocess.run(cmd, check=True) except subprocess.CalledProcessError as e: - log.error( - f"An error ocurred while trying to download '{name}' source-code:\n{e}" - ) + log.error(f"An error ocurred while trying to download '{name}' source-code:\n{e}") raise log.info("Done.") @@ -158,8 +156,8 @@ def download_from_gh_latest(dest_dir: Path, owner: str, name: str): Returns the download url. """ - latest_release_link_url = ( - "https://api.github.com/repos/{}/{}/releases/latest".format(owner, name) + latest_release_link_url = "https://api.github.com/repos/{}/{}/releases/latest".format( + owner, name ) print("Fetching latest release with:", latest_release_link_url) @@ -318,8 +316,6 @@ def test_fixtures(cls): type="content", ), Repo("Maven", "new_repo3", local_basepath=FIXTURE_WORKDIR, type="content"), - Repo( - "Docs Tool", "pulp-docs", local_basepath=FIXTURE_WORKDIR, type="other" - ), + Repo("Docs Tool", "pulp-docs", local_basepath=FIXTURE_WORKDIR, type="other"), ] return Repos(core_repo=DEFAULT_CORE, content_repos=DEFAULT_CONTENT_REPOS) diff --git a/src/pulp_docs/utils/aggregation.py b/src/pulp_docs/utils/aggregation.py index 9cd1af6..fd54e1e 100644 --- a/src/pulp_docs/utils/aggregation.py +++ b/src/pulp_docs/utils/aggregation.py @@ -116,9 +116,7 @@ def repo_grouping( lookup_path = self._parse_template_str(template_str, repo.name) _repo_content = self.get_children(lookup_path) if _repo_content: - _nav[repo.title] = ( - _repo_content if len(_repo_content) > 1 else _repo_content[0] - ) + _nav[repo.title] = _repo_content if len(_repo_content) > 1 else _repo_content[0] # Expand content-types else: for repo in selected_repos: @@ -133,9 +131,7 @@ def repo_grouping( for content_type in selected_content: # Get repo files from content-type and persona - lookup_path = self._parse_template_str( - template_str, repo.name, content_type - ) + lookup_path = self._parse_template_str(template_str, repo.name, content_type) _repo_content = self.get_children(lookup_path) # Prevent rendering content-type section if there are no files