Skip to content

Commit

Permalink
Merge pull request #22 from cidrblock/chore_darglint
Browse files Browse the repository at this point in the history
Enable darglint via pre-commit
  • Loading branch information
cidrblock authored Apr 24, 2023
2 parents 4f63e92 + 53d4bd7 commit cec00d4
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 12 deletions.
7 changes: 7 additions & 0 deletions .darglint
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 33 additions & 8 deletions antsichaut/antsichaut.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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:
Expand Down Expand Up @@ -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()
Expand All @@ -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)

Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit cec00d4

Please sign in to comment.