From 53d4bd7c381dff309819255ec828f87d57e35d53 Mon Sep 17 00:00:00 2001 From: cidrblock Date: Mon, 24 Apr 2023 08:52:21 -0700 Subject: [PATCH] Enable darglint via pre-commit --- .darglint | 7 +++++++ .pre-commit-config.yaml | 8 ++++---- antsichaut/antsichaut.py | 41 ++++++++++++++++++++++++++++++++-------- 3 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 .darglint diff --git a/.darglint b/.darglint new file mode 100644 index 0000000..8e68aa3 --- /dev/null +++ b/.darglint @@ -0,0 +1,7 @@ +[darglint] +# NOTE: All `darglint` styles except for `sphinx` hit ridiculously low +# NOTE: performance on some of the in-project Python modules. +# Refs: +# * https://github.com/terrencepreilly/darglint/issues/186 +docstring_style = sphinx +strictness = full diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4549e9f..71ef3a9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -52,10 +52,10 @@ repos: - id: cspell name: Spell check with cspell - # - repo: https://github.com/terrencepreilly/darglint.git - # rev: v1.8.1 - # hooks: - # - id: darglint + - repo: https://github.com/terrencepreilly/darglint.git + rev: v1.8.1 + hooks: + - id: darglint # - repo: https://github.com/pycqa/pylint.git # rev: v3.0.0a6 diff --git a/antsichaut/antsichaut.py b/antsichaut/antsichaut.py index e084dba..03590be 100755 --- a/antsichaut/antsichaut.py +++ b/antsichaut/antsichaut.py @@ -33,7 +33,10 @@ def __init__( # noqa: PLR0913 @cached_property def _get_request_headers(self): - """Get headers for GitHub API request.""" + """Get headers for GitHub API request. + + :return: The constructed headers + """ headers = {"Accept": "application/vnd.github.v3+json"} # if the user adds `GITHUB_TOKEN` add it to API Request # required for `private` repositories @@ -43,7 +46,11 @@ def _get_request_headers(self): return headers def _get_release_id(self, release_version): - """Get ID of a specific release.""" + """Get ID of a specific release. + + :param release_version: The version of the release + :return: The release ID + """ url = ("{base_url}/repos/{repo_name}/releases/tags/{version}").format( base_url=self.github_api_url, repo_name=self.repository, @@ -68,7 +75,11 @@ def _get_release_id(self, release_version): return release_id def _get_release_date(self, release_version): - """Using GitHub API gets latest release date.""" + """Using GitHub API gets latest release date. + + :param release_version: The version of the release + :return: The release date + """ if release_version == "latest": version = release_version else: @@ -99,7 +110,10 @@ def _get_release_date(self, release_version): return published_date def _write_changelog(self, string_data): - """Write changelog to the changelog file.""" + """Write changelog to the changelog file. + + :param string_data: The changelog data + """ with self.filename.open(mode="r+") as file: # read the existing data and store it in a variable yaml = YAML() @@ -109,12 +123,19 @@ def _write_changelog(self, string_data): @staticmethod def _get_changelog_line(item): - """Generate each line of changelog.""" + """Generate each line of changelog. + + :param item: The item to generate the line for + :return: The generated line + """ return "{title} ({url})".format(title=item["title"], url=item["url"]) def get_changes_after_last_release(self): - """Get all the merged pull request after specified release - until optionally specified release. + """Get all the merged pull request. + + Only after specified release, optionally until specified release. + + :return: The list of pull requests """ since_release_date = self._get_release_date(self.since_version) @@ -194,7 +215,11 @@ def remove_outdated(self, changes, data, new_version): del current_changes[change_type][idx] def parse_changelog(self, changes): # noqa: C901, PLR0912 - """Parse the pull requests data and return a string.""" + """Parse the pull requests data and return a string. + + :param changes: The list of PRs + :return: A dictionary representing the complete changelog + """ yaml = YAML()