diff hgext/convert/filemap.py @ 51686:39033e7a6e0a

convert: stringify `shlex` class argument The documentation is handwavy, but typeshed says this should be `str`[1]. I'm not sure if this is the correct encoding (vs `fsencode` or "latin1" like the tokens returned by the proxy class). While we're here, we can add a few more type hints that would have caused pytype to flag the problem. [1] https://github.com/python/typeshed/blob/6a9b53e719a139c2d6b41cf265ed0990cf438192/stdlib/shlex.pyi#L51
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 11 Jul 2024 21:16:45 -0400
parents 0eb515c7bec8
children f4733654f144
line wrap: on
line diff
--- a/hgext/convert/filemap.py	Thu Jul 11 20:54:06 2024 -0400
+++ b/hgext/convert/filemap.py	Thu Jul 11 21:16:45 2024 -0400
@@ -76,7 +76,7 @@
     rename: MutableMapping[bytes, bytes]
     targetprefixes: Optional[Set[bytes]]
 
-    def __init__(self, ui: "uimod.ui", path=None) -> None:
+    def __init__(self, ui: "uimod.ui", path: Optional[bytes] = None) -> None:
         self.ui = ui
         self.include = {}
         self.exclude = {}
@@ -86,8 +86,7 @@
             if self.parse(path):
                 raise error.Abort(_(b'errors in filemap'))
 
-    # TODO: cmd==b'source' case breaks if ``path``is str
-    def parse(self, path) -> int:
+    def parse(self, path: Optional[bytes]) -> int:
         errs = 0
 
         def check(name: bytes, mapping, listname: bytes):
@@ -218,7 +217,9 @@
 
 
 class filemap_source(common.converter_source):
-    def __init__(self, ui: "uimod.ui", baseconverter, filemap) -> None:
+    def __init__(
+        self, ui: "uimod.ui", baseconverter, filemap: Optional[bytes]
+    ) -> None:
         super(filemap_source, self).__init__(ui, baseconverter.repotype)
         self.base = baseconverter
         self.filemapper = filemapper(ui, filemap)