From 0b7cb848db421001f20b9063631000e589f12caa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 7 Sep 2024 00:48:02 -0600 Subject: [PATCH 1/7] build(deps-dev): bump mypy from 1.10.1 to 1.11.2 (#1009) * build(deps-dev): bump mypy from 1.10.1 to 1.11.2 * chore(pre-commit): bump mypy from 1.10.0 to 1.11.2 --- .pre-commit-config.yaml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4acf01e2e..7b559cea1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -50,7 +50,7 @@ repos: name: ruff (format) - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v1.10.0" + rev: "v1.11.2" hooks: - id: mypy additional_dependencies: diff --git a/pyproject.toml b/pyproject.toml index f7785e7e5..18193a5a7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,7 +76,7 @@ dev = [ "ruff == 0.5.0" ] mypy = [ - "mypy == 1.10.1", + "mypy == 1.11.2", "types-requests ~= 2.32.0", ] From 297f612cdafc7c54efe843f6a911a3a3c9fbf312 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 7 Sep 2024 00:48:53 -0600 Subject: [PATCH 2/7] build(deps-dev): bump ruff from 0.5.0 to 0.6.1 (#1006) * build(deps-dev): bump ruff from 0.5.0 to 0.6.1 * chore(pre-commit): bump ruff plugin from 0.5.0 to 0.6.1 --- .pre-commit-config.yaml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7b559cea1..842903553 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,7 +37,7 @@ repos: # Linters and validation - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.0 + rev: v0.6.1 hooks: - id: ruff name: ruff (lint) diff --git a/pyproject.toml b/pyproject.toml index 18193a5a7..242021dfe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,7 +73,7 @@ test = [ dev = [ "pre-commit ~= 3.5", "tox ~= 4.11", - "ruff == 0.5.0" + "ruff == 0.6.1" ] mypy = [ "mypy == 1.11.2", From d84efc7719a8679e6979d513d1c8c60904af7384 Mon Sep 17 00:00:00 2001 From: Will Yardley Date: Tue, 24 Sep 2024 18:55:25 -0700 Subject: [PATCH 3/7] docs: update docstrings to resolve sphinx failures (#1030) set `ignore-module-all` for `autodoc_default_options` to resolve some Sphinx errors about duplicate / ambiguous references https://github.com/sphinx-doc/sphinx/issues/4961#issuecomment-1543858623 Standardize some non-standard (Google-ish) docstrings to Sphinx format, to avoid ruff and Sphinx arguing about underline length. Fix indents and other minor whitespace / formatting changes. Fixes #1029 --- docs/conf.py | 2 + semantic_release/cli/commands/version.py | 17 ++--- semantic_release/hvcs/gitea.py | 9 ++- semantic_release/hvcs/gitlab.py | 81 ++++++++---------------- semantic_release/hvcs/util.py | 8 ++- 5 files changed, 45 insertions(+), 72 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 9c026c4b8..da9f2cda5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,6 +16,8 @@ "sphinxcontrib.apidoc", ] +autodoc_default_options = {"ignore-module-all": True} + templates_path = ["_templates"] source_suffix = ".rst" master_doc = "index" diff --git a/semantic_release/cli/commands/version.py b/semantic_release/cli/commands/version.py index 503d7bf1e..5461cdd2d 100644 --- a/semantic_release/cli/commands/version.py +++ b/semantic_release/cli/commands/version.py @@ -219,19 +219,12 @@ def build_distributions( """ Run the build command to build the distributions. - Arguments: - --------- - build_command: str | None - The build command to run - build_command_env: Mapping[str, str] | None - The environment variables to use when running the build command - noop: bool - Whether or not to run the build command - - Raises: - ------ - BuildDistributionsError: if the build command fails + :param build_command: The build command to run. + :param build_command_env: The environment variables to use when running the + build command. + :param noop: Whether or not to run the build command. + :raises: BuildDistributionsError: if the build command fails """ if not build_command: rprint("[green]No build command specified, skipping") diff --git a/semantic_release/hvcs/gitea.py b/semantic_release/hvcs/gitea.py index 12f52e850..3ae2e6ab4 100644 --- a/semantic_release/hvcs/gitea.py +++ b/semantic_release/hvcs/gitea.py @@ -95,11 +95,9 @@ def create_release( Ref: https://gitea.com/api/swagger#/repository/repoCreateRelease :param tag: Tag to create release for - :param release_notes: The release notes for this version - :param prerelease: Whether or not this release should be specified as a - prerelease + prerelease :return: Whether the request succeeded """ @@ -181,6 +179,7 @@ def get_release_id_by_tag(self, tag: str) -> int | None: Get a release by its tag name https://gitea.com/api/swagger#/repository/repoGetReleaseByTag :param tag: Tag to get release for + :return: ID of found release """ tag_endpoint = self.create_api_url( @@ -206,6 +205,7 @@ def edit_release_notes(self, release_id: int, release_notes: str) -> int: https://gitea.com/api/swagger#/repository/repoEditRelease :param id: ID of release to update :param release_notes: The release notes for this version + :return: The ID of the release that was edited """ log.info("Updating release %s", release_id) @@ -231,6 +231,7 @@ def create_or_update_release( Post release changelog :param version: The version number :param changelog: The release notes for this version + :return: The status of the request """ log.info("Creating release for %s", tag) @@ -274,6 +275,7 @@ def upload_release_asset( :param release_id: ID of the release to upload to :param file: Path of the file to upload :param label: this parameter has no effect + :return: The status of the request """ url = self.asset_upload_url(release_id) @@ -312,6 +314,7 @@ def upload_dists(self, tag: str, dist_glob: str) -> int: Upload distributions to a release :param tag: Tag to upload for :param path: Path to the dist directory + :return: The number of distributions successfully uploaded """ # Find the release corresponding to this tag diff --git a/semantic_release/hvcs/gitlab.py b/semantic_release/hvcs/gitlab.py index f5452c4ca..1a9437b76 100644 --- a/semantic_release/hvcs/gitlab.py +++ b/semantic_release/hvcs/gitlab.py @@ -106,23 +106,16 @@ def create_release( """ Create a release in a remote VCS, adding any release notes and assets to it - Arguments: - --------- - tag(str): The tag to create the release for - release_notes(str): The changelog description for this version only - prerelease(bool): This parameter has no effect in GitLab - assets(list[str]): A list of paths to files to upload as assets (TODO: not implemented) - noop(bool): If True, do not perform any actions, only log intents - - Returns: - ------- - str: The tag of the release - - Raises: - ------ - GitlabAuthenticationError: If authentication is not correct - GitlabCreateError: If the server cannot perform the request + :param tag: The tag to create the release for + :param release_notes: The changelog description for this version only + :param prerelease: This parameter has no effect in GitLab + :param assets: A list of paths to files to upload as assets (TODO: not implemented) + :param noop: If True, do not perform any actions, only log intents + :return: The tag of the release + + :raises: GitlabAuthenticationError: If authentication is not correct + :raises: GitlabCreateError: If the server cannot perform the request """ if noop: noop_report(f"would have created a release for tag {tag}") @@ -145,20 +138,13 @@ def create_release( @suppress_not_found def get_release_by_tag(self, tag: str) -> gitlab.v4.objects.ProjectRelease | None: """ - Get a release by its tag name - - Arguments: - --------- - tag(str): The tag name to get the release for + Get a release by its tag name. - Returns: - ------- - gitlab.v4.objects.ProjectRelease | None: The release object or None if not found + :param tag: The tag name to get the release for - Raises: - ------ - gitlab.exceptions.GitlabAuthenticationError: If the user is not authenticated + :return: gitlab.v4.objects.ProjectRelease or None if not found + :raises: gitlab.exceptions.GitlabAuthenticationError: If the user is not authenticated """ try: return self.project.releases.get(tag) @@ -175,21 +161,15 @@ def edit_release_notes( # type: ignore[override] release_notes: str, ) -> str: """ - Update the release notes for a given release + Update the release notes for a given release. - Arguments: - --------- - release(gitlab.v4.objects.ProjectRelease): The release object to update - release_notes(str): The new release notes + :param release: The release object to update + :param release_notes: The new release notes - Returns: - ------- - str: The release id + :return: The release id - Raises: - ------ - GitlabAuthenticationError: If authentication is not correct - GitlabUpdateError: If the server cannot perform the request + :raises: GitlabAuthenticationError: If authentication is not correct + :raises: GitlabUpdateError: If the server cannot perform the request """ log.info( @@ -206,24 +186,17 @@ def create_or_update_release( self, tag: str, release_notes: str, prerelease: bool = False ) -> str: """ - Create or update a release for the given tag in a remote VCS - - Arguments: - --------- - tag(str): The tag to create or update the release for - release_notes(str): The changelog description for this version only - prerelease(bool): This parameter has no effect in GitLab + Create or update a release for the given tag in a remote VCS. - Returns: - ------- - str: The release id + :param tag: The tag to create or update the release for + :param release_notes: The changelog description for this version only + :p