@@ -50,10 +50,10 @@ class ReleaseTypes(IntEnum):
5050
5151 github_scitools : str = "upstream"
5252 github_fork : str = "origin"
53- github_user : str = None
54- patch_min_max_tag : tuple [str , str ] = None
55- git_tag : str = None # v1.2.3rc0
56- sha256 : str = None
53+ github_user : typing . Optional [ str ] = None
54+ patch_min_max_tag : typing . Optional [ tuple [str , str ] ] = None
55+ git_tag : typing . Optional [ str ] = None # v1.2.3rc0
56+ sha256 : typing . Optional [ str ] = None
5757
5858 @classmethod
5959 def get_cmd_description (cls ) -> str :
@@ -157,8 +157,12 @@ def _git_ls_remote_tags(self) -> str:
157157 def _get_tagged_versions (self ) -> list [IrisVersion ]:
158158 tag_regex = re .compile (r"(?<=refs/tags/).*$" )
159159 scitools_tags_raw = self ._git_ls_remote_tags ().splitlines ()
160+ scitools_tags_searched = [
161+ tag_regex .search (line ) for line in scitools_tags_raw
162+ ]
160163 scitools_tags = [
161- tag_regex .search (line ).group (0 ) for line in scitools_tags_raw
164+ search .group (0 ) for search in scitools_tags_searched
165+ if search is not None
162166 ]
163167
164168 def get_version (tag : str ) -> IrisVersion | None :
@@ -179,6 +183,7 @@ def get_version(tag: str) -> IrisVersion | None:
179183
180184 def get_release_tag (self ):
181185 def validate (input_tag : str ) -> str | None :
186+ result = None
182187 try :
183188 version = IrisVersion (input_tag )
184189 except InvalidVersion as err :
@@ -193,7 +198,8 @@ def validate(input_tag: str) -> str | None:
193198 "Please try again ..."
194199 )
195200 else :
196- return input_tag # v1.2.3rc0
201+ result = input_tag # v1.2.3rc0
202+ return result
197203
198204 message = (
199205 "Input the release tag you are creating today, including any "
@@ -313,10 +319,11 @@ def patch_min_max(self) -> tuple[IrisVersion, IrisVersion] | None:
313319
314320 @property
315321 def more_patches_after_this_one (self ) -> bool :
316- if self .release_type is self .ReleaseTypes .PATCH :
317- return self .version < self .patch_min_max [1 ]
318- else :
319- return False
322+ return (
323+ self .release_type is self .ReleaseTypes .PATCH and
324+ self .patch_min_max is not None and
325+ self .version < self .patch_min_max [1 ]
326+ )
320327
321328 def apply_patches (self ):
322329 if self .release_type is self .ReleaseTypes .PATCH :
@@ -338,15 +345,15 @@ def apply_patches(self):
338345 case "" :
339346 message = (
340347 f"Propose the patch change(s) against { self .version .branch } via "
341- f"pull request(s). Targetting { self .version .branch } will "
348+ f"pull request(s). Targeting { self .version .branch } will "
342349 "avoid later Git conflicts."
343350 )
344351 case _:
345352 message = (
346353 "Create pull request(s) cherry-picking the patch change(s) "
347354 f"from { patch_branch } into { self .version .branch } .\n "
348355 "cherry-picking will cause Git conflicts later in the "
349- "release process; in future consider targetting the patch "
356+ "release process; in future consider targeting the patch "
350357 "change(s) directly at the release branch."
351358 )
352359
@@ -410,7 +417,7 @@ def validate(self) -> None:
410417 f"First release in { self .version .series } series?" : self .first_in_series ,
411418 "Current latest Iris release" : max (self ._get_tagged_versions ()),
412419 }
413- if self .release_type is self .ReleaseTypes .PATCH :
420+ if self .release_type is self .ReleaseTypes .PATCH and self . patch_min_max is not None :
414421 status ["Series being patched" ] = (
415422 f"{ self .patch_min_max [0 ].series } to { self .patch_min_max [1 ].series } "
416423 )
@@ -533,7 +540,7 @@ def _delete_local_branch(self, branch_name: str):
533540 class WhatsNewRsts (typing .NamedTuple ):
534541 latest : Path
535542 release : Path
536- index : Path
543+ index_ : Path
537544 template : Path
538545
539546 @property
@@ -574,7 +581,7 @@ def finalise_whats_new(self):
574581 self .wait_for_done (message )
575582
576583 message = (
577- f"In { self .whats_news .index .absolute ()} :\n "
584+ f"In { self .whats_news .index_ .absolute ()} :\n "
578585 f"Replace references to { self .whats_news .latest .name } with "
579586 f"{ self .whats_news .release .name } "
580587 )
@@ -650,8 +657,8 @@ def finalise_whats_new(self):
650657 message = (
651658 "Commit and push all the What's New changes.\n "
652659 f"git add { self .whats_news .release .absolute ()} ;\n "
653- f"git add { self .whats_news .index .absolute ()} ;\n "
654- f'git commit -m "Whats new updates for { self .version } .";\n '
660+ f"git add { self .whats_news .index_ .absolute ()} ;\n "
661+ f'git commit -m "Whats-New updates for { self .version } .";\n '
655662 f"git push -u { self .github_fork } { working_branch } ;"
656663 )
657664 self .wait_for_done (message )
@@ -828,8 +835,10 @@ def validate(sha256_string: str) -> str | None:
828835
829836 if not valid :
830837 self .report_problem ("Invalid SHA256 hash. Please try again ..." )
838+ result = None
831839 else :
832- return sha256_string
840+ result = sha256_string
841+ return result
833842
834843 message = (
835844 f"Visit the below and click `view hashes` for the Source Distribution"
@@ -1196,7 +1205,7 @@ def next_series_patch() -> IrisVersion:
11961205 self .wait_for_done (message )
11971206
11981207 message = (
1199- f"In { self .whats_news .index .absolute ()} :\n "
1208+ f"In { self .whats_news .index_ .absolute ()} :\n "
12001209 f"Add { self .whats_news .latest .name } to the top of the list of .rst "
12011210 f"files, "
12021211 f"and set the top include:: to be { self .whats_news .latest .name } ."
@@ -1205,8 +1214,8 @@ def next_series_patch() -> IrisVersion:
12051214
12061215 message = (
12071216 "Commit and push all the What's New changes.\n "
1208- f"git add { self .whats_news .index .absolute ()} ;\n "
1209- 'git commit -m "Restore latest Whats New files.";\n '
1217+ f"git add { self .whats_news .index_ .absolute ()} ;\n "
1218+ 'git commit -m "Restore latest Whats- New files.";\n '
12101219 f"git push -u { self .github_fork } { working_branch } ;"
12111220 )
12121221 self .wait_for_done (message )
0 commit comments