Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 94c02b3

Browse filesBrowse files
bearomorphismLee-W
authored andcommitted
refactor(default): capitalize all constants and remove unnecessary variable
1 parent a0cc490 commit 94c02b3
Copy full SHA for 94c02b3

File tree

8 files changed

+27
-28
lines changed
Filter options

8 files changed

+27
-28
lines changed

‎commitizen/bump.py

Copy file name to clipboardExpand all lines: commitizen/bump.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from string import Template
99
from typing import cast
1010

11-
from commitizen.defaults import MAJOR, MINOR, PATCH, bump_message, encoding
11+
from commitizen.defaults import BUMP_MESSAGE, ENCODING, MAJOR, MINOR, PATCH
1212
from commitizen.exceptions import CurrentVersionNotFoundError
1313
from commitizen.git import GitCommit, smart_open
1414
from commitizen.version_schemes import Increment, Version
@@ -64,7 +64,7 @@ def update_version_in_files(
6464
files: list[str],
6565
*,
6666
check_consistency: bool = False,
67-
encoding: str = encoding,
67+
encoding: str = ENCODING,
6868
) -> list[str]:
6969
"""Change old version to the new one in every file given.
7070
@@ -121,7 +121,7 @@ def _bump_with_regex(
121121
current_version: str,
122122
new_version: str,
123123
regex: str,
124-
encoding: str = encoding,
124+
encoding: str = ENCODING,
125125
) -> tuple[bool, str]:
126126
current_version_found = False
127127
lines = []
@@ -148,6 +148,6 @@ def create_commit_message(
148148
message_template: str | None = None,
149149
) -> str:
150150
if message_template is None:
151-
message_template = bump_message
151+
message_template = BUMP_MESSAGE
152152
t = Template(message_template)
153153
return t.safe_substitute(current_version=current_version, new_version=new_version)

‎commitizen/commands/changelog.py

Copy file name to clipboardExpand all lines: commitizen/commands/changelog.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def __init__(self, config: BaseConfig, args):
7878
self.change_type_order = (
7979
self.config.settings.get("change_type_order")
8080
or self.cz.change_type_order
81-
or defaults.change_type_order
81+
or defaults.CHANGE_TYPE_ORDER
8282
)
8383
self.rev_range = args.get("rev_range")
8484
self.tag_format: str = (

‎commitizen/commands/init.py

Copy file name to clipboardExpand all lines: commitizen/commands/init.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from commitizen.__version__ import __version__
1212
from commitizen.config import BaseConfig, JsonConfig, TomlConfig, YAMLConfig
1313
from commitizen.cz import registry
14-
from commitizen.defaults import DEFAULT_SETTINGS, config_files
14+
from commitizen.defaults import CONFIG_FILES, DEFAULT_SETTINGS
1515
from commitizen.exceptions import InitFailedError, NoAnswersError
1616
from commitizen.git import get_latest_tag_name, get_tag_names, smart_open
1717
from commitizen.version_schemes import KNOWN_SCHEMES, Version, get_version_scheme
@@ -165,7 +165,7 @@ def _ask_config_path(self) -> str:
165165

166166
name: str = questionary.select(
167167
"Please choose a supported config file: ",
168-
choices=config_files,
168+
choices=CONFIG_FILES,
169169
default=default_path,
170170
style=self.cz.style,
171171
).unsafe_ask()

‎commitizen/config/__init__.py

Copy file name to clipboardExpand all lines: commitizen/config/__init__.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def read_cfg(filepath: str | None = None) -> BaseConfig:
2828
cfg_paths = (
2929
path / Path(filename)
3030
for path in cfg_search_paths
31-
for filename in defaults.config_files
31+
for filename in defaults.CONFIG_FILES
3232
)
3333

3434
for filename in cfg_paths:

‎commitizen/cz/conventional_commits/conventional_commits.py

Copy file name to clipboardExpand all lines: commitizen/cz/conventional_commits/conventional_commits.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ def parse_subject(text):
2828

2929

3030
class ConventionalCommitsCz(BaseCommitizen):
31-
bump_pattern = defaults.bump_pattern
32-
bump_map = defaults.bump_map
33-
bump_map_major_version_zero = defaults.bump_map_major_version_zero
31+
bump_pattern = defaults.BUMP_PATTERN
32+
bump_map = defaults.BUMP_MAP
33+
bump_map_major_version_zero = defaults.BUMP_MAP_MAJOR_VERSION_ZERO
3434
commit_parser = r"^((?P<change_type>feat|fix|refactor|perf|BREAKING CHANGE)(?:\((?P<scope>[^()\r\n]*)\)|\()?(?P<breaking>!)?|\w+!):\s(?P<message>.*)?" # noqa
3535
change_type_map = {
3636
"feat": "Feat",
3737
"fix": "Fix",
3838
"refactor": "Refactor",
3939
"perf": "Perf",
4040
}
41-
changelog_pattern = defaults.bump_pattern
41+
changelog_pattern = defaults.BUMP_PATTERN
4242

4343
def questions(self) -> Questions:
4444
questions: Questions = [

‎commitizen/cz/customize/customize.py

Copy file name to clipboardExpand all lines: commitizen/cz/customize/customize.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121

2222

2323
class CustomizeCommitsCz(BaseCommitizen):
24-
bump_pattern = defaults.bump_pattern
25-
bump_map = defaults.bump_map
26-
bump_map_major_version_zero = defaults.bump_map_major_version_zero
27-
change_type_order = defaults.change_type_order
24+
bump_pattern = defaults.BUMP_PATTERN
25+
bump_map = defaults.BUMP_MAP
26+
bump_map_major_version_zero = defaults.BUMP_MAP_MAJOR_VERSION_ZERO
27+
change_type_order = defaults.CHANGE_TYPE_ORDER
2828

2929
def __init__(self, config: BaseConfig):
3030
super().__init__(config)

‎commitizen/defaults.py

Copy file name to clipboardExpand all lines: commitizen/defaults.py
+9-10Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ class Settings(TypedDict, total=False):
6060
extras: dict[str, Any]
6161

6262

63-
name: str = "cz_conventional_commits"
64-
config_files: list[str] = [
63+
CONFIG_FILES: list[str] = [
6564
"pyproject.toml",
6665
".cz.toml",
6766
".cz.json",
@@ -70,10 +69,10 @@ class Settings(TypedDict, total=False):
7069
"cz.yaml",
7170
"cz.toml",
7271
]
73-
encoding: str = "utf-8"
72+
ENCODING = "utf-8"
7473

7574
DEFAULT_SETTINGS: Settings = {
76-
"name": name,
75+
"name": "cz_conventional_commits",
7776
"version": None,
7877
"version_files": [],
7978
"version_provider": "commitizen",
@@ -102,7 +101,7 @@ class Settings(TypedDict, total=False):
102101
"pre_bump_hooks": [],
103102
"post_bump_hooks": [],
104103
"prerelease_offset": 0,
105-
"encoding": encoding,
104+
"encoding": ENCODING,
106105
"always_signoff": False,
107106
"template": None, # default provided by plugin
108107
"extras": {},
@@ -114,8 +113,8 @@ class Settings(TypedDict, total=False):
114113

115114
CHANGELOG_FORMAT = "markdown"
116115

117-
bump_pattern = r"^((BREAKING[\-\ ]CHANGE|\w+)(\(.+\))?!?):"
118-
bump_map = OrderedDict(
116+
BUMP_PATTERN = r"^((BREAKING[\-\ ]CHANGE|\w+)(\(.+\))?!?):"
117+
BUMP_MAP = OrderedDict(
119118
(
120119
(r"^.+!$", MAJOR),
121120
(r"^BREAKING[\-\ ]CHANGE", MAJOR),
@@ -125,7 +124,7 @@ class Settings(TypedDict, total=False):
125124
(r"^perf", PATCH),
126125
)
127126
)
128-
bump_map_major_version_zero = OrderedDict(
127+
BUMP_MAP_MAJOR_VERSION_ZERO = OrderedDict(
129128
(
130129
(r"^.+!$", MINOR),
131130
(r"^BREAKING[\-\ ]CHANGE", MINOR),
@@ -135,8 +134,8 @@ class Settings(TypedDict, total=False):
135134
(r"^perf", PATCH),
136135
)
137136
)
138-
change_type_order = ["BREAKING CHANGE", "Feat", "Fix", "Refactor", "Perf"]
139-
bump_message = "bump: version $current_version → $new_version"
137+
CHANGE_TYPE_ORDER = ["BREAKING CHANGE", "Feat", "Fix", "Refactor", "Perf"]
138+
BUMP_MESSAGE = "bump: version $current_version → $new_version"
140139

141140

142141
def get_tag_regexes(

‎tests/test_conf.py

Copy file name to clipboardExpand all lines: tests/test_conf.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def test_find_git_project_root(tmpdir):
151151

152152

153153
@pytest.mark.parametrize(
154-
"config_files_manager", defaults.config_files.copy(), indirect=True
154+
"config_files_manager", defaults.CONFIG_FILES.copy(), indirect=True
155155
)
156156
def test_set_key(config_files_manager):
157157
_conf = config.read_cfg()
@@ -162,7 +162,7 @@ def test_set_key(config_files_manager):
162162

163163
class TestReadCfg:
164164
@pytest.mark.parametrize(
165-
"config_files_manager", defaults.config_files.copy(), indirect=True
165+
"config_files_manager", defaults.CONFIG_FILES.copy(), indirect=True
166166
)
167167
def test_load_conf(_, config_files_manager):
168168
cfg = config.read_cfg()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.