Skip to content

Commit

Permalink
Format docstrings to use triple-quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
nwiltsie committed Aug 2, 2024
1 parent 644ce8e commit f66c0b3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions bumpchanges/bump.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"Work with CHANGELOG.md files."
"""Work with CHANGELOG.md files."""

import argparse
import datetime
Expand Down Expand Up @@ -31,7 +31,7 @@ def update_changelog(


def write_commit_details(version: str):
"Write text snippets for the eventual commit and pull request."
"""Write text snippets for the eventual commit and pull request."""
outputs = {}

actor = os.environ["GITHUB_ACTOR"]
Expand Down Expand Up @@ -84,7 +84,7 @@ def write_commit_details(version: str):


def entrypoint():
"Main entrypoint."
"""Main entrypoint."""
parser = argparse.ArgumentParser()
parser.add_argument("changelog", type=Path)
parser.add_argument("repo_url", type=str)
Expand Down
26 changes: 13 additions & 13 deletions bumpchanges/changelog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"Classes to handle parsing and updating CHANGELOG.md files."
"""Classes to handle parsing and updating CHANGELOG.md files."""

import datetime
import itertools
Expand All @@ -15,15 +15,15 @@


class ChangelogError(Exception):
"Indicate a fundamental problem with the CHANGELOG structure."
"""Indicate a fundamental problem with the CHANGELOG structure."""


class EmptyListError(Exception):
"Indicate that a section is empty and should be stripped."
"""Indicate that a section is empty and should be stripped."""


def parse_heading(tokens: list[Token]) -> tuple[str, Token]:
"Parse the `inline` element from the heading."
"""Parse the `inline` element from the heading."""
if (
len(tokens) < 3
or tokens[0].type != "heading_open"
Expand All @@ -39,7 +39,7 @@ def parse_heading(tokens: list[Token]) -> tuple[str, Token]:


def parse_bullet_list(tokens: list[Token]) -> list[Token]:
"Consume tokens and return all of the child list_items."
"""Consume tokens and return all of the child list_items."""
# Parse the heading
if not tokens or tokens[0].type != "bullet_list_open":
raise EmptyListError()
Expand All @@ -63,7 +63,7 @@ def parse_bullet_list(tokens: list[Token]) -> list[Token]:


def heading(level: int, children: list):
"Return a heading of the appropriate level."
"""Return a heading of the appropriate level."""

markup = "#" * level
tag = f"h{level}"
Expand All @@ -83,7 +83,7 @@ def heading(level: int, children: list):

@dataclass
class Version:
"Class to help manage individual releases within CHANGELOG.md files."
"""Class to help manage individual releases within CHANGELOG.md files."""

link_heading_re: ClassVar = re.compile(
r"^\[(?P<version>.+?)\]\((?P<link>.+?)\)(?:\s+-\s+(?P<date>.*))?$"
Expand All @@ -108,12 +108,12 @@ class Version:

@classmethod
def blank_unreleased(cls):
"Create a new empty Unreleased version."
"""Create a new empty Unreleased version."""
return cls(version="Unreleased")

@classmethod
def from_tokens(cls, tokens):
"Parse a Version from a token stream."
"""Parse a Version from a token stream."""
# Open, content, close
if (
len(tokens) < 3
Expand Down Expand Up @@ -186,7 +186,7 @@ def from_tokens(cls, tokens):
return cls(**kwargs)

def serialize(self):
"Yield a stream of markdown tokens describing this Version."
"""Yield a stream of markdown tokens describing this Version."""

link_kwargs = {}
if self.link:
Expand Down Expand Up @@ -247,7 +247,7 @@ def serialize(self):


class Changelog:
"Class to help manage CHANGELOG.md files."
"""Class to help manage CHANGELOG.md files."""

def __init__(self, changelog_file: Path, repo_url: str):
self.changelog_file = changelog_file
Expand Down Expand Up @@ -305,7 +305,7 @@ def __init__(self, changelog_file: Path, repo_url: str):
raise ChangelogError("No versions!")

def update_version(self, next_version: str, date: datetime.date):
"Move all unreleased changes under the new version."
"""Move all unreleased changes under the new version."""
if not self.versions or self.versions[0].version != "Unreleased":
logging.getLogger(__name__).warning(
"No Unreleased section - adding a new empty section"
Expand All @@ -318,7 +318,7 @@ def update_version(self, next_version: str, date: datetime.date):
self.versions[0].date = date.isoformat()

def render(self) -> str:
"Render the CHANGELOG to markdown."
"""Render the CHANGELOG to markdown."""
renderer = mdformat.renderer.MDRenderer()

options = {}
Expand Down
6 changes: 3 additions & 3 deletions bumpchanges/getversion.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"Get the next tag version."
"""Get the next tag version."""

import argparse
import re
Expand All @@ -14,7 +14,7 @@


def get_next_version(repo_dir: Path, bump_type: str, exact_version: str) -> str:
"Return the next tag after the appropriate bump type."
"""Return the next tag after the appropriate bump type."""
logger = getLogger(__name__)

if bump_type == "exact":
Expand Down Expand Up @@ -69,7 +69,7 @@ def get_next_version(repo_dir: Path, bump_type: str, exact_version: str) -> str:


def entrypoint():
"Main entrypoint for this module."
"""Main entrypoint for this module."""
setup_logging()

parser = argparse.ArgumentParser()
Expand Down
10 changes: 5 additions & 5 deletions bumpchanges/logging.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"Module to handle logging to GitHub Actions."
"""Module to handle logging to GitHub Actions."""

import logging

Expand All @@ -7,15 +7,15 @@


class NoticeLogger(logging.getLoggerClass()):
"A logger subclass that has an additional NOTICE level."
"""A logger subclass that has an additional NOTICE level."""

def notice(self, msg, *args, **kwargs):
"Log the message at NOTICE level."
"""Log the message at NOTICE level."""
self.log(NOTICE, msg, *args, **kwargs)


class GHAFilter(logging.Filter):
"A logging filter that plays nice with GitHub Actions output."
"""A logging filter that plays nice with GitHub Actions output."""

# pylint: disable=too-few-public-methods

Expand All @@ -34,7 +34,7 @@ def filter(self, record):


def setup_logging():
"Set up logging to GitHub Actions.logger."
"""Set up logging to GitHub Actions.logger."""
# Does this need to be re-entrant like this?
if logging.getLevelName("NOTICE") == NOTICE:
return
Expand Down

0 comments on commit f66c0b3

Please sign in to comment.