Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 07eaf84

Browse files
committed
refactor: misc cleanup
1 parent 856ca4f commit 07eaf84

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

commitizen/cz/conventional_commits/conventional_commits.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ConventionalCommitsCz(BaseCommitizen):
4141
changelog_pattern = defaults.BUMP_PATTERN
4242

4343
def questions(self) -> Questions:
44-
questions: Questions = [
44+
return [
4545
{
4646
"type": "list",
4747
"name": "prefix",
@@ -146,7 +146,6 @@ def questions(self) -> Questions:
146146
),
147147
},
148148
]
149-
return questions
150149

151150
def message(self, answers: dict) -> str:
152151
prefix = answers["prefix"]
@@ -165,9 +164,7 @@ def message(self, answers: dict) -> str:
165164
if footer:
166165
footer = f"\n\n{footer}"
167166

168-
message = f"{prefix}{scope}: {subject}{body}{footer}"
169-
170-
return message
167+
return f"{prefix}{scope}: {subject}{body}{footer}"
171168

172169
def example(self) -> str:
173170
return (
@@ -188,25 +185,21 @@ def schema(self) -> str:
188185
)
189186

190187
def schema_pattern(self) -> str:
191-
PATTERN = (
188+
return (
192189
r"(?s)" # To explicitly make . match new line
193190
r"(build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert|bump)" # type
194191
r"(\(\S+\))?!?:" # scope
195192
r"( [^\n\r]+)" # subject
196193
r"((\n\n.*)|(\s*))?$"
197194
)
198-
return PATTERN
199195

200196
def info(self) -> str:
201197
dir_path = os.path.dirname(os.path.realpath(__file__))
202198
filepath = os.path.join(dir_path, "conventional_commits_info.txt")
203199
with open(filepath, encoding=self.config.settings["encoding"]) as f:
204-
content = f.read()
205-
return content
200+
return f.read()
206201

207202
def process_commit(self, commit: str) -> str:
208-
pat = re.compile(self.schema_pattern())
209-
m = re.match(pat, commit)
210-
if m is None:
211-
return ""
212-
return m.group(3).strip()
203+
if m := re.match(self.schema_pattern(), commit):
204+
return m.group(3).strip()
205+
return ""

commitizen/cz/jira/jira.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class JiraSmartCz(BaseCommitizen):
1010
def questions(self) -> Questions:
11-
questions = [
11+
return [
1212
{
1313
"type": "input",
1414
"name": "message",
@@ -42,7 +42,6 @@ def questions(self) -> Questions:
4242
"filter": lambda x: "#comment " + x if x else "",
4343
},
4444
]
45-
return questions
4645

4746
def message(self, answers: dict) -> str:
4847
return " ".join(
@@ -77,5 +76,4 @@ def info(self) -> str:
7776
dir_path = os.path.dirname(os.path.realpath(__file__))
7877
filepath = os.path.join(dir_path, "jira_info.txt")
7978
with open(filepath, encoding=self.config.settings["encoding"]) as f:
80-
content = f.read()
81-
return content
79+
return f.read()

0 commit comments

Comments
 (0)