pick-ui: use more expressive variable names
authorEric Engestrom <eric@engestrom.ch>
Wed, 3 Nov 2021 20:36:11 +0000 (20:36 +0000)
committerMarge Bot <emma+marge@anholt.net>
Sat, 7 Oct 2023 19:00:17 +0000 (19:00 +0000)
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13664>

bin/pick/core.py
bin/pick/core_test.py

index 4f956a2..d7dfb12 100644 (file)
@@ -276,11 +276,11 @@ async def resolve_nomination(commit: 'Commit', version: str) -> 'Commit':
     out = _out.decode()
 
     # We give precedence to fixes and cc tags over revert tags.
-    if m := IS_FIX.search(out):
+    if fix_for_commit := IS_FIX.search(out):
         # We set the nomination_type and because_sha here so that we can later
         # check to see if this fixes another staged commit.
         try:
-            commit.because_sha = fixed = await full_sha(m.group(1))
+            commit.because_sha = fixed = await full_sha(fix_for_commit.group(1))
         except PickUIException:
             pass
         else:
@@ -289,16 +289,16 @@ async def resolve_nomination(commit: 'Commit', version: str) -> 'Commit':
                 commit.nominated = True
                 return commit
 
-    if m := IS_CC.search(out):
-        if m.groups() == (None, None) or version in m.groups():
+    if cc_to := IS_CC.search(out):
+        if cc_to.groups() == (None, None) or version in cc_to.groups():
             commit.nominated = True
             commit.nomination_type = NominationType.CC
             return commit
 
-    if m := IS_REVERT.search(out):
+    if revert_of := IS_REVERT.search(out):
         # See comment for IS_FIX path
         try:
-            commit.because_sha = reverted = await full_sha(m.group(1))
+            commit.because_sha = reverted = await full_sha(revert_of.group(1))
         except PickUIException:
             pass
         else:
index e178f64..f2ac6ed 100644 (file)
@@ -94,9 +94,9 @@ class TestRE:
                 Reviewed-by: Jonathan Marek <jonathan@marek.ca>
             """)
 
-            m = core.IS_FIX.search(message)
-            assert m is not None
-            assert m.group(1) == '3d09bb390a39'
+            fix_for_commit = core.IS_FIX.search(message)
+            assert fix_for_commit is not None
+            assert fix_for_commit.group(1) == '3d09bb390a39'
 
     class TestCC:
 
@@ -114,9 +114,9 @@ class TestRE:
                 Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
             """)
 
-            m = core.IS_CC.search(message)
-            assert m is not None
-            assert m.group(1) == '19.2'
+            cc_to = core.IS_CC.search(message)
+            assert cc_to is not None
+            assert cc_to.group(1) == '19.2'
 
         def test_multiple_branches(self):
             """Tests commit with more than one branch specified"""
@@ -130,10 +130,10 @@ class TestRE:
                 Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
             """)
 
-            m = core.IS_CC.search(message)
-            assert m is not None
-            assert m.group(1) == '19.1'
-            assert m.group(2) == '19.2'
+            cc_to = core.IS_CC.search(message)
+            assert cc_to is not None
+            assert cc_to.group(1) == '19.1'
+            assert cc_to.group(2) == '19.2'
 
         def test_no_branch(self):
             """Tests commit with no branch specification"""
@@ -148,8 +148,8 @@ class TestRE:
                 Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
             """)
 
-            m = core.IS_CC.search(message)
-            assert m is not None
+            cc_to = core.IS_CC.search(message)
+            assert cc_to is not None
 
         def test_quotes(self):
             """Tests commit with quotes around the versions"""
@@ -162,9 +162,9 @@ class TestRE:
                  Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3454>
             """)
 
-            m = core.IS_CC.search(message)
-            assert m is not None
-            assert m.group(1) == '20.0'
+            cc_to = core.IS_CC.search(message)
+            assert cc_to is not None
+            assert cc_to.group(1) == '20.0'
 
         def test_multiple_quotes(self):
             """Tests commit with quotes around the versions"""
@@ -177,10 +177,10 @@ class TestRE:
                  Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3454>
             """)
 
-            m = core.IS_CC.search(message)
-            assert m is not None
-            assert m.group(1) == '20.0'
-            assert m.group(2) == '20.1'
+            cc_to = core.IS_CC.search(message)
+            assert cc_to is not None
+            assert cc_to.group(1) == '20.0'
+            assert cc_to.group(2) == '20.1'
 
         def test_single_quotes(self):
             """Tests commit with quotes around the versions"""
@@ -193,9 +193,9 @@ class TestRE:
                  Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3454>
             """)
 
-            m = core.IS_CC.search(message)
-            assert m is not None
-            assert m.group(1) == '20.0'
+            cc_to = core.IS_CC.search(message)
+            assert cc_to is not None
+            assert cc_to.group(1) == '20.0'
 
         def test_multiple_single_quotes(self):
             """Tests commit with quotes around the versions"""
@@ -208,10 +208,10 @@ class TestRE:
                  Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3454>
             """)
 
-            m = core.IS_CC.search(message)
-            assert m is not None
-            assert m.group(1) == '20.0'
-            assert m.group(2) == '20.1'
+            cc_to = core.IS_CC.search(message)
+            assert cc_to is not None
+            assert cc_to.group(1) == '20.0'
+            assert cc_to.group(2) == '20.1'
 
     class TestRevert:
 
@@ -232,9 +232,9 @@ class TestRE:
                 Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
             """)
 
-            m = core.IS_REVERT.search(message)
-            assert m is not None
-            assert m.group(1) == '2ca8629fa9b303e24783b76a7b3b0c2513e32fbd'
+            revert_of = core.IS_REVERT.search(message)
+            assert revert_of is not None
+            assert revert_of.group(1) == '2ca8629fa9b303e24783b76a7b3b0c2513e32fbd'
 
 
 class TestResolveNomination: