Skip to content

refactor: move ruff and black from the format file to the pre-commit hooks #724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions commitizen/bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion commitizen/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 0 additions & 9 deletions scripts/format

This file was deleted.

4 changes: 0 additions & 4 deletions tests/commands/test_changelog_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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")

Expand Down
1 change: 0 additions & 1 deletion tests/commands/test_check_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down