1111import urllib .parse
1212import urllib .request
1313
14- from gi .repository import GLib
14+ from gi .repository import GLib # type: ignore[import-untyped]
1515
1616
1717def load_cache (path ):
@@ -29,8 +29,8 @@ def load_cache(path):
2929
3030class CommitCache :
3131 def __init__ (self , commit_map ):
32- self .commit_map : dict [str , list [str | None ]] = commit_map
33- self .dirtree_map : dict [str | None ] = {}
32+ self .commit_map : dict [str | None , list [str | None ]] = commit_map
33+ self .dirtree_map : dict [str | None , str | None ] = {}
3434 self .modified = False
3535
3636 # Backwards compat, re-resolve all commits where we don't have root dirtree info
@@ -74,7 +74,7 @@ def update_from_summary(self, branch: str):
7474 if commit and not self .has_commit (commit ):
7575 self .update_for_commit (commit , branch )
7676
77- def update_for_commit (self , commit : str | None , known_branch : str | None = None ):
77+ def update_for_commit (self , commit : str , known_branch : str | None = None ):
7878 ref = known_branch
7979 root_dirtree = None
8080 url = f"https://dl.flathub.org/repo/objects/{ commit [0 :2 ]} /{ commit [2 :]} .commit"
@@ -200,7 +200,10 @@ def parse_log(logname: str, cache: CommitCache, ignore_deltas=False):
200200 if first_line == "" :
201201 return []
202202
203- match = fastly_log_re .match (first_line )
203+ first_line_str = (
204+ first_line .decode ("utf-8" ) if isinstance (first_line , bytes ) else first_line
205+ )
206+ match = fastly_log_re .match (first_line_str )
204207 if match :
205208 line_re = fastly_log_re
206209 else :
@@ -219,7 +222,8 @@ def parse_log(logname: str, cache: CommitCache, ignore_deltas=False):
219222
220223 if line == "" :
221224 break
222- match = line_re .match (line )
225+ line_str = line .decode ("utf-8" ) if isinstance (line , bytes ) else line
226+ match = line_re .match (line_str )
223227 if not match :
224228 sys .stderr .write (f"Warning: Can't match line: { line [:- 1 ]} \n " )
225229 continue
@@ -229,7 +233,7 @@ def parse_log(logname: str, cache: CommitCache, ignore_deltas=False):
229233 if op != "GET" or result != "200" :
230234 continue
231235
232- target_ref : str = match .group (10 )
236+ target_ref : str | None = match .group (10 )
233237 if len (target_ref ) == 0 :
234238 target_ref = None
235239
0 commit comments