From bb2f8a79afc586f782f3728aa09665dcc509fbb3 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Tue, 26 Nov 2024 09:36:45 +0800 Subject: [PATCH] style: fix ruff warned style --- commitizen/changelog.py | 3 ++- commitizen/changelog_formats/restructuredtext.py | 4 ++-- commitizen/cli.py | 3 ++- commitizen/cz/__init__.py | 2 +- commitizen/cz/base.py | 3 ++- commitizen/defaults.py | 3 ++- commitizen/version_schemes.py | 3 +-- tests/conftest.py | 2 +- tests/providers/conftest.py | 2 +- 9 files changed, 14 insertions(+), 11 deletions(-) diff --git a/commitizen/changelog.py b/commitizen/changelog.py index 32a66c47eb..7f300354b6 100644 --- a/commitizen/changelog.py +++ b/commitizen/changelog.py @@ -29,9 +29,10 @@ import re from collections import OrderedDict, defaultdict +from collections.abc import Iterable from dataclasses import dataclass from datetime import date -from typing import TYPE_CHECKING, Iterable +from typing import TYPE_CHECKING from jinja2 import ( BaseLoader, diff --git a/commitizen/changelog_formats/restructuredtext.py b/commitizen/changelog_formats/restructuredtext.py index 09d032400c..8bcf9a4a4f 100644 --- a/commitizen/changelog_formats/restructuredtext.py +++ b/commitizen/changelog_formats/restructuredtext.py @@ -3,7 +3,7 @@ import re import sys from itertools import zip_longest -from typing import IO, TYPE_CHECKING, Any, Tuple, Union +from typing import IO, TYPE_CHECKING, Any, Union from commitizen.changelog import Metadata @@ -18,7 +18,7 @@ # Can't use `|` operator and native type because of https://bugs.python.org/issue42233 only fixed in 3.10 -TitleKind: TypeAlias = Union[str, Tuple[str, str]] +TitleKind: TypeAlias = Union[str, tuple[str, str]] class RestructuredText(BaseFormat): diff --git a/commitizen/cli.py b/commitizen/cli.py index 1e0b1c6276..2ee7d41eba 100644 --- a/commitizen/cli.py +++ b/commitizen/cli.py @@ -3,11 +3,12 @@ import argparse import logging import sys +from collections.abc import Sequence from copy import deepcopy from functools import partial from pathlib import Path from types import TracebackType -from typing import Any, Sequence +from typing import Any import argcomplete from decli import cli diff --git a/commitizen/cz/__init__.py b/commitizen/cz/__init__.py index 04603a9ec4..cb17fe32cd 100644 --- a/commitizen/cz/__init__.py +++ b/commitizen/cz/__init__.py @@ -4,7 +4,7 @@ import pkgutil import sys import warnings -from typing import Iterable +from collections.abc import Iterable if sys.version_info >= (3, 10): from importlib import metadata diff --git a/commitizen/cz/base.py b/commitizen/cz/base.py index 70929e2f83..43455a74ca 100644 --- a/commitizen/cz/base.py +++ b/commitizen/cz/base.py @@ -1,7 +1,8 @@ from __future__ import annotations from abc import ABCMeta, abstractmethod -from typing import Any, Callable, Iterable, Protocol +from collections.abc import Iterable +from typing import Any, Callable, Protocol from jinja2 import BaseLoader, PackageLoader from prompt_toolkit.styles import Style, merge_styles diff --git a/commitizen/defaults.py b/commitizen/defaults.py index 996c243196..d776e38d7a 100644 --- a/commitizen/defaults.py +++ b/commitizen/defaults.py @@ -2,7 +2,8 @@ import pathlib from collections import OrderedDict -from typing import Any, Iterable, MutableMapping, TypedDict +from collections.abc import Iterable, MutableMapping +from typing import Any, TypedDict # Type Questions = Iterable[MutableMapping[str, Any]] diff --git a/commitizen/version_schemes.py b/commitizen/version_schemes.py index 346287a065..554864e3bf 100644 --- a/commitizen/version_schemes.py +++ b/commitizen/version_schemes.py @@ -10,7 +10,6 @@ ClassVar, Literal, Protocol, - Type, cast, runtime_checkable, ) @@ -150,7 +149,7 @@ def bump( # With PEP 440 and SemVer semantic, Scheme is the type, Version is an instance Version: TypeAlias = VersionProtocol -VersionScheme: TypeAlias = Type[VersionProtocol] +VersionScheme: TypeAlias = type[VersionProtocol] class BaseVersion(_BaseVersion): diff --git a/tests/conftest.py b/tests/conftest.py index 95f3df3b20..1e6bc15f0c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,8 +3,8 @@ import os import re import tempfile +from collections.abc import Iterator from pathlib import Path -from typing import Iterator import pytest from pytest_mock import MockerFixture diff --git a/tests/providers/conftest.py b/tests/providers/conftest.py index b4432ca524..f73cdb72a5 100644 --- a/tests/providers/conftest.py +++ b/tests/providers/conftest.py @@ -1,8 +1,8 @@ from __future__ import annotations import os +from collections.abc import Iterator from pathlib import Path -from typing import Iterator import pytest