From f66c0b306483a2d05a613379f38dd9b700b89ec0 Mon Sep 17 00:00:00 2001 From: Nicholas Wiltsie Date: Fri, 2 Aug 2024 09:48:50 -0700 Subject: [PATCH] Format docstrings to use triple-quotes --- bumpchanges/bump.py | 6 +++--- bumpchanges/changelog.py | 26 +++++++++++++------------- bumpchanges/getversion.py | 6 +++--- bumpchanges/logging.py | 10 +++++----- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/bumpchanges/bump.py b/bumpchanges/bump.py index 61597d8..4aef2bd 100644 --- a/bumpchanges/bump.py +++ b/bumpchanges/bump.py @@ -1,4 +1,4 @@ -"Work with CHANGELOG.md files." +"""Work with CHANGELOG.md files.""" import argparse import datetime @@ -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"] @@ -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) diff --git a/bumpchanges/changelog.py b/bumpchanges/changelog.py index 4e8ad78..59dff15 100644 --- a/bumpchanges/changelog.py +++ b/bumpchanges/changelog.py @@ -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 @@ -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" @@ -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() @@ -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}" @@ -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.+?)\]\((?P.+?)\)(?:\s+-\s+(?P.*))?$" @@ -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 @@ -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: @@ -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 @@ -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" @@ -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 = {} diff --git a/bumpchanges/getversion.py b/bumpchanges/getversion.py index fcb2c8f..4680664 100644 --- a/bumpchanges/getversion.py +++ b/bumpchanges/getversion.py @@ -1,4 +1,4 @@ -"Get the next tag version." +"""Get the next tag version.""" import argparse import re @@ -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": @@ -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() diff --git a/bumpchanges/logging.py b/bumpchanges/logging.py index 196a4dd..70da98a 100644 --- a/bumpchanges/logging.py +++ b/bumpchanges/logging.py @@ -1,4 +1,4 @@ -"Module to handle logging to GitHub Actions." +"""Module to handle logging to GitHub Actions.""" import logging @@ -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 @@ -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