From 1dd2af8ea7931e77732f88b400ecea9031c8b792 Mon Sep 17 00:00:00 2001 From: LeeW Date: Fri, 22 Nov 2019 23:21:01 -0500 Subject: [PATCH 1/2] fix(cz/exceptions): Fix AnswerRequiredException not caught inherit CzException --- commitizen/cz/exceptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commitizen/cz/exceptions.py b/commitizen/cz/exceptions.py index 89b19788b7..2597b68813 100644 --- a/commitizen/cz/exceptions.py +++ b/commitizen/cz/exceptions.py @@ -2,5 +2,5 @@ class CzException(Exception): ... -class AnswerRequiredError(Exception): +class AnswerRequiredError(CzException): ... From 2be7a95e953af3b9a9fd8dc50fb58f76edbd6edc Mon Sep 17 00:00:00 2001 From: LeeW Date: Fri, 22 Nov 2019 23:47:55 -0500 Subject: [PATCH 2/2] style(all): run ./script/lint --- commitizen/cli.py | 1 - commitizen/commands/__init__.py | 5 ++--- commitizen/commands/check.py | 8 +++++--- commitizen/cz/__init__.py | 2 +- tests/test_bump_command.py | 2 +- tests/test_commands.py | 15 +++++---------- tests/test_cz_customize.py | 2 +- 7 files changed, 15 insertions(+), 20 deletions(-) diff --git a/commitizen/cli.py b/commitizen/cli.py index be6103226a..4b667e1715 100644 --- a/commitizen/cli.py +++ b/commitizen/cli.py @@ -7,7 +7,6 @@ from commitizen import commands, config, out - logger = logging.getLogger(__name__) data = { "prog": "cz", diff --git a/commitizen/commands/__init__.py b/commitizen/commands/__init__.py index ea17a8a5f3..051429f52f 100644 --- a/commitizen/commands/__init__.py +++ b/commitizen/commands/__init__.py @@ -1,11 +1,10 @@ from .bump import Bump -from .commit import Commit from .check import Check +from .commit import Commit from .example import Example from .info import Info from .list_cz import ListCz from .schema import Schema from .version import Version -__all__ = ("Bump", "Check", "Commit", "Example", "Info", "ListCz", "Schema", - "Version") +__all__ = ("Bump", "Check", "Commit", "Example", "Info", "ListCz", "Schema", "Version") diff --git a/commitizen/commands/check.py b/commitizen/commands/check.py index 67a449a03d..3ebb8c5f9e 100644 --- a/commitizen/commands/check.py +++ b/commitizen/commands/check.py @@ -3,8 +3,10 @@ from commitizen import out -PATTERN = (r'(build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert)' - r'(\([\w\-]+\))?:\s.*') +PATTERN = ( + r"(build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert)" + r"(\([\w\-]+\))?:\s.*" +) NO_COMMIT_MSG = 3 INVALID_COMMIT_MSG = 5 @@ -46,7 +48,7 @@ def __call__(self): def _get_commit_msg(self): temp_filename: str = self.arguments.get("commit_msg_file") - return open(temp_filename, 'r').read() + return open(temp_filename, "r").read() def _is_conventional(self, pattern, commit_msg): return re.match(PATTERN, commit_msg) diff --git a/commitizen/cz/__init__.py b/commitizen/cz/__init__.py index 5951b722d1..3c379f3c6b 100644 --- a/commitizen/cz/__init__.py +++ b/commitizen/cz/__init__.py @@ -2,8 +2,8 @@ import pkgutil from commitizen.cz.conventional_commits import ConventionalCommitsCz -from commitizen.cz.jira import JiraSmartCz from commitizen.cz.customize import CustomizeCommitsCz +from commitizen.cz.jira import JiraSmartCz registry = { "cz_conventional_commits": ConventionalCommitsCz, diff --git a/tests/test_bump_command.py b/tests/test_bump_command.py index f39668145c..209a5efe53 100644 --- a/tests/test_bump_command.py +++ b/tests/test_bump_command.py @@ -1,7 +1,7 @@ +import errno import os import shutil import stat -import errno import sys import uuid from pathlib import Path diff --git a/tests/test_commands.py b/tests/test_commands.py index 210e392352..6aaae55eef 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -179,12 +179,11 @@ def test_check_no_conventional_commit(mocker): with get_temp_dir() as dir: tempfile = os.path.join(dir, "temp_commit_file") - with open(tempfile, 'w') as f: + with open(tempfile, "w") as f: f.write("no conventional commit") check_cmd = commands.Check( - config=config, - arguments={"commit_msg_file": tempfile} + config=config, arguments={"commit_msg_file": tempfile} ) check_cmd() error_mock.assert_called_once() @@ -195,12 +194,11 @@ def test_check_conventional_commit(mocker): with get_temp_dir() as dir: tempfile = os.path.join(dir, "temp_commit_file") - with open(tempfile, 'w') as f: + with open(tempfile, "w") as f: f.write("feat(lang): added polish language") check_cmd = commands.Check( - config=config, - arguments={"commit_msg_file": tempfile} + config=config, arguments={"commit_msg_file": tempfile} ) check_cmd() @@ -209,7 +207,4 @@ def test_check_conventional_commit(mocker): def test_check_command_when_commit_file_not_found(): with pytest.raises(FileNotFoundError): - commands.Check( - config=config, - arguments={"commit_msg_file": ""} - )() + commands.Check(config=config, arguments={"commit_msg_file": ""})() diff --git a/tests/test_cz_customize.py b/tests/test_cz_customize.py index 21fb1272e5..56d58811e5 100644 --- a/tests/test_cz_customize.py +++ b/tests/test_cz_customize.py @@ -1,8 +1,8 @@ import pytest from tomlkit import parse -from commitizen.cz.customize import CustomizeCommitsCz from commitizen.config import Config +from commitizen.cz.customize import CustomizeCommitsCz @pytest.fixture(scope="module")