Skip to content

Turn on isort for ruff #1128

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

Merged
merged 4 commits into from
May 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

### Feat

- **config_files**: add suport for "cz.toml" config file
- **config_files**: add support for "cz.toml" config file

## v3.26.2 (2024-05-22)

3 changes: 1 addition & 2 deletions commitizen/changelog_formats/__init__.py
Original file line number Diff line number Diff line change
@@ -5,9 +5,8 @@
import importlib_metadata as metadata

from commitizen.changelog import Metadata
from commitizen.exceptions import ChangelogFormatUnknown
from commitizen.config.base_config import BaseConfig

from commitizen.exceptions import ChangelogFormatUnknown

CHANGELOG_FORMAT_ENTRYPOINT = "commitizen.changelog_format"
TEMPLATE_EXTENSION = "j2"
2 changes: 1 addition & 1 deletion commitizen/changelog_formats/restructuredtext.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
import re
import sys
from itertools import zip_longest
from typing import IO, TYPE_CHECKING, Any, Union, Tuple
from typing import IO, TYPE_CHECKING, Any, Tuple, Union

from commitizen.changelog import Metadata

4 changes: 2 additions & 2 deletions commitizen/commands/bump.py
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import questionary

from commitizen import bump, factory, git, hooks, out
from commitizen.changelog_formats import get_changelog_format
from commitizen.commands.changelog import Changelog
from commitizen.config import BaseConfig
from commitizen.exceptions import (
@@ -21,13 +22,12 @@
NotAllowed,
NoVersionSpecifiedError,
)
from commitizen.changelog_formats import get_changelog_format
from commitizen.providers import get_provider
from commitizen.version_schemes import (
get_version_scheme,
Increment,
InvalidVersion,
Prerelease,
get_version_scheme,
)

logger = getLogger("commitizen")
7 changes: 3 additions & 4 deletions commitizen/commands/changelog.py
Original file line number Diff line number Diff line change
@@ -7,9 +7,10 @@
from typing import Callable, cast

from commitizen import bump, changelog, defaults, factory, git, out

from commitizen.changelog_formats import get_changelog_format
from commitizen.config import BaseConfig
from commitizen.cz.base import MessageBuilderHook, ChangelogReleaseHook
from commitizen.cz.base import ChangelogReleaseHook, MessageBuilderHook
from commitizen.cz.utils import strip_local_version
from commitizen.exceptions import (
DryRunExit,
NoCommitsFoundError,
@@ -18,10 +19,8 @@
NotAGitProjectError,
NotAllowed,
)
from commitizen.changelog_formats import get_changelog_format
from commitizen.git import GitTag, smart_open
from commitizen.version_schemes import get_version_scheme
from commitizen.cz.utils import strip_local_version


class Changelog:
1 change: 0 additions & 1 deletion commitizen/commands/commit.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
import contextlib
import os


import questionary

from commitizen import factory, git, out
1 change: 1 addition & 0 deletions commitizen/commands/init.py
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@

import questionary
import yaml

from commitizen import cmd, factory, out
from commitizen.__version__ import __version__
from commitizen.config import BaseConfig, JsonConfig, TomlConfig, YAMLConfig
2 changes: 1 addition & 1 deletion commitizen/config/__init__.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
from pathlib import Path

from commitizen import defaults, git
from commitizen.exceptions import ConfigFileNotFound, ConfigFileIsEmpty
from commitizen.exceptions import ConfigFileIsEmpty, ConfigFileNotFound

from .base_config import BaseConfig
from .json_config import JsonConfig
2 changes: 1 addition & 1 deletion commitizen/config/json_config.py
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@

import json
from pathlib import Path
from commitizen.exceptions import InvalidConfigurationError

from commitizen.exceptions import InvalidConfigurationError
from commitizen.git import smart_open

from .base_config import BaseConfig
1 change: 1 addition & 0 deletions commitizen/config/toml_config.py
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
from tomlkit import exceptions, parse, table

from commitizen.exceptions import InvalidConfigurationError

from .base_config import BaseConfig


2 changes: 1 addition & 1 deletion commitizen/config/yaml_config.py
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@

import yaml

from commitizen.git import smart_open
from commitizen.exceptions import InvalidConfigurationError
from commitizen.git import smart_open

from .base_config import BaseConfig

4 changes: 2 additions & 2 deletions commitizen/cz/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import re
import os
import re
import tempfile

from commitizen.cz import exceptions
from commitizen import git
from commitizen.cz import exceptions


def required_validator(answer, msg=None):
4 changes: 1 addition & 3 deletions commitizen/defaults.py
Original file line number Diff line number Diff line change
@@ -2,9 +2,7 @@

import pathlib
from collections import OrderedDict
from typing import Any, Iterable, MutableMapping

from typing import TypedDict
from typing import Any, Iterable, MutableMapping, TypedDict

# Type
Questions = Iterable[MutableMapping[str, Any]]
1 change: 0 additions & 1 deletion commitizen/providers/__init__.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@

from commitizen.config.base_config import BaseConfig
from commitizen.exceptions import VersionProviderUnknown

from commitizen.providers.base_provider import VersionProvider
from commitizen.providers.cargo_provider import CargoProvider
from commitizen.providers.commitizen_provider import CommitizenProvider
1 change: 0 additions & 1 deletion commitizen/providers/cargo_provider.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@

import tomlkit


from commitizen.providers.base_provider import TomlProvider


1 change: 0 additions & 1 deletion commitizen/providers/commitizen_provider.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations


from commitizen.providers.base_provider import VersionProvider


1 change: 0 additions & 1 deletion commitizen/providers/composer_provider.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations


from commitizen.providers.base_provider import JsonProvider


1 change: 0 additions & 1 deletion commitizen/providers/npm_provider.py
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
from pathlib import Path
from typing import Any, ClassVar


from commitizen.providers.base_provider import VersionProvider


1 change: 0 additions & 1 deletion commitizen/providers/pep621_provider.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations


from commitizen.providers.base_provider import TomlProvider


1 change: 0 additions & 1 deletion commitizen/providers/poetry_provider.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@

import tomlkit


from commitizen.providers.base_provider import TomlProvider


6 changes: 2 additions & 4 deletions commitizen/providers/scm_provider.py
Original file line number Diff line number Diff line change
@@ -3,17 +3,15 @@
import re
from typing import Callable


from commitizen.git import get_tags
from commitizen.providers.base_provider import VersionProvider
from commitizen.version_schemes import (
get_version_scheme,
InvalidVersion,
Version,
VersionProtocol,
get_version_scheme,
)

from commitizen.providers.base_provider import VersionProvider


class ScmProvider(VersionProvider):
"""
700 changes: 318 additions & 382 deletions poetry.lock

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -63,8 +63,6 @@ pytest-mock = "^3.10"
pytest-regressions = "^2.4.0"
pytest-freezer = "^0.4.6"
pytest-xdist = "^3.1.0"
# code formatter
black = ">=23.11,<25.0"
# linter
ruff = ">=0.1.6,<0.5.0"
pre-commit = ">=2.18,<4.0"
@@ -149,7 +147,16 @@ addopts = "--strict-markers"
line-length = 88

[tool.ruff.lint]
select = ["E", "F", "UP"]
select = [
# pycodestyle
"E",
# Pyflakes
"F",
# pyupgrade
"UP",
# isort
"I",
]
ignore = [
"E501",
"D1",
3 changes: 2 additions & 1 deletion scripts/format
Original file line number Diff line number Diff line change
@@ -5,5 +5,6 @@ export PREFIX="poetry run python -m "

set -x

# This is needed for running import sorting
${PREFIX}ruff check --fix commitizen tests
${PREFIX}ruff format commitizen tests
${PREFIX}black commitizen tests
1 change: 0 additions & 1 deletion scripts/test
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ export PREFIX='poetry run python -m '
export REGEX='^(?![.]|venv).*'

${PREFIX}pytest -n 3 --dist=loadfile --cov-report term-missing --cov-report=xml:coverage.xml --cov=commitizen tests/
${PREFIX}black commitizen tests
${PREFIX}ruff check commitizen/ tests/ --fix
${PREFIX}mypy commitizen/ tests/
${PREFIX}commitizen -nr 3 check --rev-range origin/master..
2 changes: 1 addition & 1 deletion tests/commands/test_bump_command.py
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@

import commitizen.commands.bump as bump
from commitizen import cli, cmd, git, hooks
from commitizen.changelog_formats import ChangelogFormat
from commitizen.cz.base import BaseCommitizen
from commitizen.exceptions import (
BumpTagFailedError,
@@ -28,7 +29,6 @@
NotAllowed,
NoVersionSpecifiedError,
)
from commitizen.changelog_formats import ChangelogFormat
from tests.utils import create_file_and_commit, create_tag, skip_below_py_3_10


4 changes: 2 additions & 2 deletions tests/commands/test_changelog_command.py
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@

from commitizen import __file__ as commitizen_init
from commitizen import cli, git
from commitizen.changelog_formats import ChangelogFormat
from commitizen.commands.changelog import Changelog
from commitizen.config.base_config import BaseConfig
from commitizen.cz.base import BaseCommitizen
@@ -22,16 +23,15 @@
NotAGitProjectError,
NotAllowed,
)
from commitizen.changelog_formats import ChangelogFormat
from tests.utils import (
create_branch,
create_file_and_commit,
create_tag,
get_current_branch,
merge_branch,
skip_below_py_3_10,
switch_branch,
wait_for_tag,
skip_below_py_3_10,
)


3 changes: 1 addition & 2 deletions tests/commands/test_commit_command.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os
import sys
from unittest.mock import ANY

import pytest
from pytest_mock import MockFixture
from unittest.mock import ANY

from commitizen import cli, cmd, commands
from commitizen.cz.exceptions import CzException
@@ -19,7 +19,6 @@
NotAllowed,
NothingToCommitError,
)

from tests.utils import skip_below_py_3_10


4 changes: 2 additions & 2 deletions tests/commands/test_example_command.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import pytest
import sys
from commitizen import cli, commands

import pytest
from pytest_mock import MockerFixture

from commitizen import cli, commands
from tests.utils import skip_below_py_3_10


5 changes: 3 additions & 2 deletions tests/commands/test_info_command.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import pytest
import sys
from commitizen import cli, commands

import pytest
from pytest_mock import MockerFixture

from commitizen import cli, commands
from tests.utils import skip_below_py_3_10


1 change: 0 additions & 1 deletion tests/commands/test_init_command.py
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@
from commitizen import cli, commands
from commitizen.__version__ import __version__
from commitizen.exceptions import InitFailedError, NoAnswersError

from tests.utils import skip_below_py_3_10


4 changes: 2 additions & 2 deletions tests/commands/test_ls_command.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import pytest
import sys
from commitizen import cli, commands

import pytest
from pytest_mock import MockerFixture

from commitizen import cli, commands
from tests.utils import skip_below_py_3_10


4 changes: 2 additions & 2 deletions tests/commands/test_schema_command.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import pytest
import sys
from commitizen import cli, commands

import pytest
from pytest_mock import MockerFixture

from commitizen import cli, commands
from tests.utils import skip_below_py_3_10


6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -10,13 +10,13 @@
from pytest_mock import MockerFixture

from commitizen import cmd, defaults
from commitizen.config import BaseConfig
from commitizen.cz import registry
from commitizen.cz.base import BaseCommitizen
from commitizen.changelog_formats import (
ChangelogFormat,
get_changelog_format,
)
from commitizen.config import BaseConfig
from commitizen.cz import registry
from commitizen.cz.base import BaseCommitizen
from tests.utils import create_file_and_commit

SIGNER = "GitHub Action"
1 change: 0 additions & 1 deletion tests/providers/test_base_provider.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations


import pytest

from commitizen.config.base_config import BaseConfig
1 change: 0 additions & 1 deletion tests/providers/test_cargo_provider.py
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
from commitizen.providers import get_provider
from commitizen.providers.cargo_provider import CargoProvider


CARGO_TOML = """\
[package]
name = "whatever"
2 changes: 0 additions & 2 deletions tests/providers/test_commitizen_provider.py
Original file line number Diff line number Diff line change
@@ -2,11 +2,9 @@

from typing import TYPE_CHECKING


from commitizen.config.base_config import BaseConfig
from commitizen.providers.commitizen_provider import CommitizenProvider


if TYPE_CHECKING:
from pytest_mock import MockerFixture

1 change: 0 additions & 1 deletion tests/providers/test_composer_provider.py
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
from commitizen.providers import get_provider
from commitizen.providers.composer_provider import ComposerProvider


COMPOSER_JSON = """\
{
"name": "whatever",
1 change: 0 additions & 1 deletion tests/providers/test_npm_provider.py
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
from commitizen.providers import get_provider
from commitizen.providers.npm_provider import NpmProvider


NPM_PACKAGE_JSON = """\
{
"name": "whatever",
1 change: 0 additions & 1 deletion tests/providers/test_pep621_provider.py
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
from commitizen.providers import get_provider
from commitizen.providers.pep621_provider import Pep621Provider


PEP621_TOML = """\
[project]
version = "0.1.0"
1 change: 0 additions & 1 deletion tests/providers/test_poetry_provider.py
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
from commitizen.providers import get_provider
from commitizen.providers.poetry_provider import PoetryProvider


POETRY_TOML = """\
[tool.poetry]
version = "0.1.0"
1 change: 0 additions & 1 deletion tests/providers/test_scm_provider.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations


import pytest

from commitizen.config.base_config import BaseConfig
3 changes: 1 addition & 2 deletions tests/test_changelog.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import re

from pathlib import Path
from typing import Optional

import pytest
from jinja2 import FileSystemLoader

from commitizen import changelog, git
from commitizen.changelog_formats import ChangelogFormat
from commitizen.cz.conventional_commits.conventional_commits import (
ConventionalCommitsCz,
)
from commitizen.exceptions import InvalidConfigurationError
from commitizen.changelog_formats import ChangelogFormat

COMMITS_DATA = [
{
3 changes: 1 addition & 2 deletions tests/test_changelog_format_asciidoc.py
Original file line number Diff line number Diff line change
@@ -5,9 +5,8 @@
import pytest

from commitizen.changelog import Metadata
from commitizen.config.base_config import BaseConfig
from commitizen.changelog_formats.asciidoc import AsciiDoc

from commitizen.config.base_config import BaseConfig

CHANGELOG_A = """
= Changelog
3 changes: 1 addition & 2 deletions tests/test_changelog_format_markdown.py
Original file line number Diff line number Diff line change
@@ -5,9 +5,8 @@
import pytest

from commitizen.changelog import Metadata
from commitizen.config.base_config import BaseConfig
from commitizen.changelog_formats.markdown import Markdown

from commitizen.config.base_config import BaseConfig

CHANGELOG_A = """
# Changelog
2 changes: 1 addition & 1 deletion tests/test_changelog_format_restructuredtext.py
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@
import pytest

from commitizen.changelog import Metadata
from commitizen.config.base_config import BaseConfig
from commitizen.changelog_formats.restructuredtext import RestructuredText
from commitizen.config.base_config import BaseConfig

if TYPE_CHECKING:
from _pytest.mark.structures import ParameterSet
3 changes: 1 addition & 2 deletions tests/test_changelog_format_textile.py
Original file line number Diff line number Diff line change
@@ -5,9 +5,8 @@
import pytest

from commitizen.changelog import Metadata
from commitizen.config.base_config import BaseConfig
from commitizen.changelog_formats.textile import Textile

from commitizen.config.base_config import BaseConfig

CHANGELOG_A = """
h1. Changelog
3 changes: 2 additions & 1 deletion tests/test_changelog_formats.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from __future__ import annotations

import pytest

from commitizen import defaults
from commitizen.config.base_config import BaseConfig
from commitizen.changelog_formats import (
KNOWN_CHANGELOG_FORMATS,
ChangelogFormat,
get_changelog_format,
guess_changelog_format,
)
from commitizen.config.base_config import BaseConfig
from commitizen.exceptions import ChangelogFormatUnknown


4 changes: 2 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -8,11 +8,11 @@

from commitizen import cli
from commitizen.exceptions import (
ConfigFileNotFound,
ExpectedExit,
InvalidCommandArgumentError,
NoCommandFoundError,
NotAGitProjectError,
InvalidCommandArgumentError,
ConfigFileNotFound,
)


2 changes: 1 addition & 1 deletion tests/test_conf.py
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
import yaml

from commitizen import config, defaults, git
from commitizen.exceptions import InvalidConfigurationError, ConfigFileIsEmpty
from commitizen.exceptions import ConfigFileIsEmpty, InvalidConfigurationError

PYPROJECT = """
[tool.commitizen]
4 changes: 2 additions & 2 deletions tests/test_git.py
Original file line number Diff line number Diff line change
@@ -6,14 +6,14 @@
import shutil

import pytest
from commitizen import cmd, exceptions, git
from pytest_mock import MockFixture

from commitizen import cmd, exceptions, git
from tests.utils import (
FakeCommand,
create_branch,
create_file_and_commit,
create_tag,
create_branch,
switch_branch,
)

2 changes: 1 addition & 1 deletion tests/test_version_schemes.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import annotations

import importlib_metadata as metadata
import pytest
from pytest_mock import MockerFixture
import importlib_metadata as metadata

from commitizen.config.base_config import BaseConfig
from commitizen.exceptions import VersionSchemeUnknown
3 changes: 1 addition & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from __future__ import annotations

import sys
import time
import uuid
import sys
from pathlib import Path

import pytest
from deprecated import deprecated

from commitizen import cmd, exceptions, git


skip_below_py_3_10 = pytest.mark.skipif(
sys.version_info < (3, 10),
reason="The output meesage of argparse is different between Python 3.10 and lower than Python 3.10",