changeset 51899:f81e0ce5103a

typing: simplify archive.gz writing and drop a few pytype suppressions I was waiting until 3.8 to use `Literal` to fix this, but there's also the ":" and "|" characters that are passed along here, meant only for the non-gz archive types. But manipulating what the local caller passes is silly- we know we're writing, so just open it for writing. As an added bonus, PyCharm stops flagging the call too (since it doesn't know about pytype suppression comments).
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 12 Sep 2024 12:53:00 -0400
parents 8c39ba94acce
children 607e94e01851
files mercurial/archival.py
diffstat 1 files changed, 1 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/archival.py	Thu Sep 12 12:38:43 2024 -0400
+++ b/mercurial/archival.py	Thu Sep 12 12:53:00 2024 -0400
@@ -163,16 +163,7 @@
                     mtime=mtime,
                 )
                 self.fileobj = gzfileobj
-                return (
-                    # taropen() wants Literal['a', 'r', 'w', 'x'] for the mode,
-                    # but Literal[] is only available in 3.8+ without the
-                    # typing_extensions backport.
-                    # pytype: disable=wrong-arg-types
-                    tarfile.TarFile.taropen(  # pytype: disable=attribute-error
-                        name, pycompat.sysstr(mode), gzfileobj
-                    )
-                    # pytype: enable=wrong-arg-types
-                )
+                return tarfile.TarFile.taropen(name, "w", gzfileobj)
             else:
                 try:
                     return tarfile.open(