public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Matt Turner" <mattst88@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoolkit:master commit in: bin/
Date: Fri, 12 Mar 2021 02:31:26 +0000 (UTC)	[thread overview]
Message-ID: <1615516276.273b4530ebb098fa140614d72532e5c6cb277df2.mattst88@gentoo> (raw)

commit:     273b4530ebb098fa140614d72532e5c6cb277df2
Author:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 12 02:24:29 2021 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Fri Mar 12 02:31:16 2021 +0000
URL:        https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=273b4530

bin: Fix type annotations

Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>

 bin/merge-driver-ekeyword | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/bin/merge-driver-ekeyword b/bin/merge-driver-ekeyword
index d24aaf9..7f4a10b 100755
--- a/bin/merge-driver-ekeyword
+++ b/bin/merge-driver-ekeyword
@@ -14,11 +14,13 @@ import os
 import sys
 import tempfile
 
-from typing import List, Optional, Tuple
+from typing import List, Optional, Sequence, Tuple
 
 from gentoolkit.ekeyword import ekeyword
 
 
+KeywordChanges = List[Tuple[Optional[List[str]], Optional[List[str]]]]
+
 def keyword_array(keyword_line: str) -> List[str]:
     # Find indices of string inside the double-quotes
     i1: int = keyword_line.find('"') + 1
@@ -28,14 +30,13 @@ def keyword_array(keyword_line: str) -> List[str]:
     return keyword_line[i1:i2].split(' ')
 
 
-def keyword_line_changes(old: str, new: str) -> List[Tuple[Optional[str],
-                                                           Optional[str]]]:
+def keyword_line_changes(old: str, new: str) -> KeywordChanges:
     a: List[str] = keyword_array(old)
     b: List[str] = keyword_array(new)
 
     s = difflib.SequenceMatcher(a=a, b=b)
 
-    changes = []
+    changes: KeywordChanges = []
     for tag, i1, i2, j1, j2 in s.get_opcodes():
         if tag == 'replace':
             changes.append((a[i1:i2], b[j1:j2]),)
@@ -48,8 +49,7 @@ def keyword_line_changes(old: str, new: str) -> List[Tuple[Optional[str],
     return changes
 
 
-def keyword_changes(ebuild1: str, ebuild2: str) -> List[Tuple[Optional[str],
-                                                              Optional[str]]]:
+def keyword_changes(ebuild1: str, ebuild2: str) -> Optional[KeywordChanges]:
     with open(ebuild1) as e1, open(ebuild2) as e2:
         lines1 = e1.readlines()
         lines2 = e2.readlines()
@@ -82,8 +82,7 @@ def keyword_changes(ebuild1: str, ebuild2: str) -> List[Tuple[Optional[str],
 
 
 def apply_keyword_changes(ebuild: str, pathname: str,
-                          changes: List[Tuple[Optional[str],
-                                              Optional[str]]]) -> int:
+                          changes: KeywordChanges) -> int:
     result: int = 0
 
     with tempfile.TemporaryDirectory() as tmpdir:
@@ -109,7 +108,7 @@ def apply_keyword_changes(ebuild: str, pathname: str,
     return result
 
 
-def main(argv):
+def main(argv: Sequence[str]) -> int:
     if len(argv) != 5:
         sys.exit(-1)
 
@@ -122,10 +121,10 @@ def main(argv):
     changes = keyword_changes(O, B)
     if changes:
         # Apply O -> B changes to A
-        result: int = apply_keyword_changes(A, P, changes)
+        result = apply_keyword_changes(A, P, changes)
         sys.exit(result)
     else:
-        result: int = os.system(f"git merge-file -L HEAD -L base -L ours {A} {O} {B}")
+        result = os.system(f"git merge-file -L HEAD -L base -L ours {A} {O} {B}")
         sys.exit(0 if result == 0 else -1)
 
 


             reply	other threads:[~2021-03-12  2:31 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-12  2:31 Matt Turner [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-06-24 18:05 [gentoo-commits] proj/gentoolkit:master commit in: bin/ Matt Turner
2024-06-24 18:05 Matt Turner
2024-06-24 18:05 Matt Turner
2024-05-25  3:45 Matt Turner
2024-05-25  3:45 Matt Turner
2024-05-25  3:45 Matt Turner
2023-08-29 15:48 Mike Gilbert
2023-08-29  1:38 Sam James
2023-08-29  0:51 Sam James
2022-12-03 13:54 Michał Górny
2022-12-03 13:54 Michał Górny
2022-07-28 15:29 Brian Dolbec
2022-07-09 19:50 Brian Dolbec
2022-05-19  4:30 Sam James
2021-02-25  0:06 Matt Turner
2020-12-31 22:11 Matt Turner
2020-03-16 14:24 Ben Kohler
2016-10-17 17:39 Paul Varner
2016-06-06 21:15 Paul Varner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1615516276.273b4530ebb098fa140614d72532e5c6cb277df2.mattst88@gentoo \
    --to=mattst88@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox