From fe2cc26b5080a4ded33db67183bd5ef0c3e991b4 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Wed, 31 Jan 2024 07:28:58 +0100 Subject: examples/chroottar.py: improve typing precision --- examples/chroottar.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/chroottar.py b/examples/chroottar.py index 523892c..8b374d1 100755 --- a/examples/chroottar.py +++ b/examples/chroottar.py @@ -13,6 +13,7 @@ import socket import sys import tarfile import tempfile +import typing if __file__.split("/")[-2:-1] == ["examples"]: sys.path.insert(0, "/".join(__file__.split("/")[:-2])) @@ -27,7 +28,10 @@ class TarFile(tarfile.TarFile): @classmethod def zstopen( - cls, name: str, mode: str = "r", fileobj: None = None + cls, + name: str, + mode: typing.Literal["r", "w", "x"] = "r", + fileobj: None = None, ) -> tarfile.TarFile: if mode not in ("r", "w", "x"): raise NotImplementedError(f"mode `{mode}' not implemented for zst") -- cgit v1.2.3