diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index da8077008b..95c2c8d39c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,14 +28,20 @@ repos: - post-commit - push + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: "v0.0.262" + hooks: + - id: ruff + stages: [commit] + + - repo: "https://github.com/psf/black" + rev: "23.3.0" + hooks: + - id: black + stages: [commit] + - repo: local hooks: - - id: format - name: format - language: system - pass_filenames: false - entry: ./scripts/format - types: [python] - id: linter and test name: linter and test diff --git a/commitizen/bump.py b/commitizen/bump.py index c405414e87..dcb6f770de 100644 --- a/commitizen/bump.py +++ b/commitizen/bump.py @@ -23,7 +23,6 @@ def find_increment( commits: List[GitCommit], regex: str, increments_map: Union[dict, OrderedDict] ) -> Optional[str]: - if isinstance(increments_map, dict): increments_map = OrderedDict(increments_map) @@ -103,7 +102,6 @@ def semver_generator(current_version: str, increment: str = None) -> str: # so it doesn't matter the increment. # Example: 1.0.0a0 with PATCH/MINOR -> 1.0.0 if not version.is_prerelease: - if increment == MAJOR: increments_version[MAJOR] += 1 increments_version[MINOR] = 0 diff --git a/commitizen/git.py b/commitizen/git.py index 2c2cb5b368..f7277bf3c5 100644 --- a/commitizen/git.py +++ b/commitizen/git.py @@ -74,7 +74,6 @@ def date(self): @classmethod def from_line(cls, line: str, inner_delimiter: str) -> "GitTag": - name, objectname, date, obj = line.split(inner_delimiter) if not obj: obj = objectname diff --git a/pyproject.toml b/pyproject.toml index dfdd021d63..acf3dad59d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,10 +58,7 @@ pytest-mock = "^3.10" pytest-regressions = "^2.4.0" pytest-freezer = "^0.4.6" pytest-xdist = "^3.1.0" -# code formatter -black = "^22.10" # linter -ruff = "^0.0.262" pre-commit = "^2.18.0" mypy = "^0.931" types-PyYAML = "^5.4.3" diff --git a/scripts/format b/scripts/format deleted file mode 100755 index e6a82477a9..0000000000 --- a/scripts/format +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env sh -set -e - -export PREFIX="poetry run python -m " - -set -x - -${PREFIX}ruff commitizen tests --fix -${PREFIX}black commitizen tests diff --git a/tests/commands/test_changelog_command.py b/tests/commands/test_changelog_command.py index bdc384c3ca..dfa135c765 100644 --- a/tests/commands/test_changelog_command.py +++ b/tests/commands/test_changelog_command.py @@ -115,7 +115,6 @@ def test_changelog_replacing_unreleased_using_incremental( def test_changelog_is_persisted_using_incremental( mocker: MockFixture, capsys, changelog_path, file_regression ): - create_file_and_commit("feat: add new output") create_file_and_commit("fix: output glitch") create_file_and_commit("Merge into master") @@ -519,7 +518,6 @@ def test_breaking_change_content_v1_multiline( def test_changelog_config_flag_increment( mocker: MockFixture, changelog_path, config_path, file_regression ): - with open(config_path, "a") as f: f.write("changelog_incremental = true\n") with open(changelog_path, "a") as f: @@ -576,7 +574,6 @@ def test_changelog_config_flag_merge_prerelease( def test_changelog_config_start_rev_option( mocker: MockFixture, capsys, config_path, file_regression ): - # create commit and tag create_file_and_commit("feat: new file") testargs = ["cz", "bump", "--yes"] @@ -738,7 +735,6 @@ def test_changelog_incremental_with_merge_prerelease( def test_changelog_with_filename_as_empty_string( mocker: MockFixture, changelog_path, config_path ): - with open(config_path, "a") as f: f.write("changelog_file = true\n") diff --git a/tests/commands/test_check_command.py b/tests/commands/test_check_command.py index 9e9182e6f2..126f56eb41 100644 --- a/tests/commands/test_check_command.py +++ b/tests/commands/test_check_command.py @@ -223,7 +223,6 @@ def test_check_command_with_invalid_argument(config): @pytest.mark.usefixtures("tmp_commitizen_project") def test_check_command_with_empty_range(config, mocker: MockFixture): - # must initialize git with a commit create_file_and_commit("feat: initial")