typing: fix the hint for the `mode` argument of `platform.copymode()`
authorMatt Harbison <matt_harbison@yahoo.com>
Sat, 10 Aug 2024 14:18:44 -0400
changeset 51799 1888846a1ee2
parent 51797 2f8e7e384178
child 51800 62806be5cbda
typing: fix the hint for the `mode` argument of `platform.copymode()` The posix module is doing a bitwise AND with this and an integer, so it can't be bytes. The only caller that provides the argument is `util.mktempcopy()`, and pytype infers the type as Any, which explains why this wasn't caught.
mercurial/posix.py
mercurial/windows.py
--- a/mercurial/posix.py	Fri May 05 06:08:36 2023 -0600
+++ b/mercurial/posix.py	Sat Aug 10 14:18:44 2024 -0400
@@ -213,7 +213,7 @@
 def copymode(
     src: bytes,
     dst: bytes,
-    mode: Optional[bytes] = None,
+    mode: Optional[int] = None,
     enforcewritable: bool = False,
 ) -> None:
     """Copy the file mode from the file at path src to dst.
--- a/mercurial/windows.py	Fri May 05 06:08:36 2023 -0600
+++ b/mercurial/windows.py	Sat Aug 10 14:18:44 2024 -0400
@@ -297,7 +297,7 @@
 def copymode(
     src: bytes,
     dst: bytes,
-    mode: Optional[bytes] = None,
+    mode: Optional[int] = None,
     enforcewritable: bool = False,
 ) -> None:
     pass