From c4a3f71a0e88e979be8cb4d44dc097ab10475ebd Mon Sep 17 00:00:00 2001 From: Simon Bengtsson Date: Wed, 10 Aug 2022 14:32:02 +0200 Subject: [PATCH] Make doc strings PEP8 compliant According to PEP8, doc strings should be 72 characters wide at most. They now are. --- .flake8 | 1 + reviewcheck/app.py | 8 +++++--- reviewcheck/common/exceptions.py | 6 +++--- reviewcheck/config.py | 12 +++++++----- tests/test_config.py | 10 ++++++---- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/.flake8 b/.flake8 index b18e48a..fca1fd0 100644 --- a/.flake8 +++ b/.flake8 @@ -1,3 +1,4 @@ [flake8] ignore = E123,W503,E722 max-line-length = 88 +max-doc-length = 72 diff --git a/reviewcheck/app.py b/reviewcheck/app.py index 439b00f..6cc5add 100755 --- a/reviewcheck/app.py +++ b/reviewcheck/app.py @@ -1,7 +1,9 @@ """ -A script to show you what threads in GitLab you've forgotten to respond to. +A script to show you what threads in GitLab you've forgotten to respond +to. -You have to configure the script before running it by running reviewcheck --configure +You have to configure the script before running it by running +reviewcheck --configure. """ import json import logging @@ -276,7 +278,7 @@ def show_reviews(config: Dict[str, Any]) -> None: for comment in discussion_data: # When minimal view is requsted, only show threads where a - # response is required + # response is required. if hide_replied_discussions: if comment["notes"][-1]["author"]["username"] == user: continue diff --git a/reviewcheck/common/exceptions.py b/reviewcheck/common/exceptions.py index 5d0aac8..0b6caf9 100644 --- a/reviewcheck/common/exceptions.py +++ b/reviewcheck/common/exceptions.py @@ -1,6 +1,6 @@ class RCException(Exception): """ - Base exception to inherit from when creating custom exceptions and to use directly - when it's not necessary to differentiate excepitons. It is caught in main and will - print the message in the exceptions. + Base exception to inherit from when creating custom exceptions and + to use directly when it's not necessary to differentiate excepitons. + It is caught in main and will print the message in the exceptions. """ diff --git a/reviewcheck/config.py b/reviewcheck/config.py index 4a62244..52b507e 100644 --- a/reviewcheck/config.py +++ b/reviewcheck/config.py @@ -14,7 +14,8 @@ def __init__(self, reconfigure: bool): self.reconfigure = reconfigure def setup_configuration(self) -> None: - # Only attempt to write the configuration file if it does not already exist + # Only attempt to write the configuration file if it does not + # already exist. if self.reconfigure or not Constants.CONFIG_PATH.exists(): Constants.CONFIG_PATH.parent.mkdir(parents=True, exist_ok=True) @@ -48,11 +49,12 @@ def setup_configuration(self) -> None: def get_configuration(self) -> Optional[Dict[str, Any]]: """ - Reads the configuration file into a dictionary. If the configuration file does - not exist, queries the user for information and writes it. + Reads the configuration file into a dictionary. If the + configuration file does not exist, queries the user for + information and writes it. - :return: A dict containing the contents of the configuration file, or None if - the file does not exist. + :return: A dict containing the contents of the configuration + file, or None if the file does not exist. """ self.setup_configuration() diff --git a/tests/test_config.py b/tests/test_config.py index 283d74a..c34c4af 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -16,10 +16,12 @@ class TestConfig(TestCase): @mock.patch("builtins.input") def test_setup_configuration(self, mock_input: mock.MagicMock) -> None: """ - Verifies that the interactive configuration setup works as expected. + Verifies that the interactive configuration setup works as + expected. """ - # The setup_configuration method reads input from the user five times in a row: + # The setup_configuration method reads input from the user five + # times in a row: # token, username, api url, jira url, and finally project IDs mock_input.side_effect = [ "very_secret", @@ -57,8 +59,8 @@ def test_setup_configuration(self, mock_input: mock.MagicMock) -> None: def test_setup_configuration_without_reconfigure(self) -> None: """ - Verifies that the configuration setup does not alter anything if the file - already exists. + Verifies that the configuration setup does not alter anything if + the file already exists. """ with tempfile.TemporaryDirectory(