@@ -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 ""
0 commit comments