2121
2222
2323class 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
28-
2924 def __init__ (self , config : BaseConfig ):
3025 super ().__init__ (config )
3126
3227 if "customize" not in self .config .settings :
3328 raise MissingCzCustomizeConfigError ()
3429 self .custom_settings = self .config .settings ["customize" ]
3530
36- custom_bump_pattern = self . custom_settings . get ( "bump_pattern" )
37- if custom_bump_pattern :
38- self . bump_pattern = custom_bump_pattern
39-
40- custom_bump_map = self . custom_settings . get ( "bump_map" )
41- if custom_bump_map :
42- self . bump_map = custom_bump_map
43-
44- custom_bump_map_major_version_zero = self . custom_settings . get (
45- "bump_map_major_version_zero"
31+ self . bump_pattern = (
32+ self . custom_settings . get ( "bump_pattern" ) or defaults . bump_pattern
33+ )
34+ self . bump_map = self . custom_settings . get ( "bump_map" ) or defaults . bump_map
35+ self . bump_map_major_version_zero = (
36+ self . custom_settings . get ( "bump_map_major_version_zero" )
37+ or defaults . bump_map_major_version_zero
38+ )
39+ self . change_type_order = (
40+ self . custom_settings . get ( "change_type_order" ) or defaults . change_type_order
4641 )
47- if custom_bump_map_major_version_zero :
48- self .bump_map_major_version_zero = custom_bump_map_major_version_zero
49-
50- custom_change_type_order = self .custom_settings .get ("change_type_order" )
51- if custom_change_type_order :
52- self .change_type_order = custom_change_type_order
5342
54- commit_parser = self .custom_settings .get ("commit_parser" )
55- if commit_parser :
43+ if commit_parser := self .custom_settings .get ("commit_parser" ):
5644 self .commit_parser = commit_parser
5745
58- changelog_pattern = self .custom_settings .get ("changelog_pattern" )
59- if changelog_pattern :
46+ if changelog_pattern := self .custom_settings .get ("changelog_pattern" ):
6047 self .changelog_pattern = changelog_pattern
6148
62- change_type_map = self .custom_settings .get ("change_type_map" )
63- if change_type_map :
49+ if change_type_map := self .custom_settings .get ("change_type_map" ):
6450 self .change_type_map = change_type_map
6551
6652 def questions (self ) -> Questions :
@@ -70,8 +56,7 @@ def message(self, answers: dict) -> str:
7056 message_template = Template (self .custom_settings .get ("message_template" , "" ))
7157 if getattr (Template , "substitute" , None ):
7258 return message_template .substitute (** answers ) # type: ignore
73- else :
74- return message_template .render (** answers )
59+ return message_template .render (** answers )
7560
7661 def example (self ) -> str :
7762 return self .custom_settings .get ("example" ) or ""
@@ -83,12 +68,7 @@ def schema(self) -> str:
8368 return self .custom_settings .get ("schema" ) or ""
8469
8570 def info (self ) -> str :
86- info_path = self .custom_settings .get ("info_path" )
87- info = self .custom_settings .get ("info" )
88- if info_path :
71+ if info_path := self .custom_settings .get ("info_path" ):
8972 with open (info_path , encoding = self .config .settings ["encoding" ]) as f :
90- content = f .read ()
91- return content
92- elif info :
93- return info
94- return ""
73+ return f .read ()
74+ return self .custom_settings .get ("info" ) or ""
0 commit comments