From adae52da073f306f94183aec3b92b4333fead930 Mon Sep 17 00:00:00 2001 From: Flavio Curella Date: Fri, 7 Feb 2025 14:43:54 -0600 Subject: [PATCH] fix typing for tar provider --- faker/providers/misc/__init__.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/faker/providers/misc/__init__.py b/faker/providers/misc/__init__.py index 7c67b5e237..8a83ad6f96 100644 --- a/faker/providers/misc/__init__.py +++ b/faker/providers/misc/__init__.py @@ -9,7 +9,7 @@ import uuid import zipfile -from typing import Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, Type, Union +from typing import Any, Callable, Dict, List, Literal, Optional, Sequence, Set, Tuple, Type, Union from typing_extensions import TypeAlias @@ -280,14 +280,13 @@ def tar( raise AssertionError( "`uncompressed_size` is smaller than the calculated minimum required size", ) + mode: Literal["w|", "w|gz", "w|bz2", "w|xz"] = "w|" if compression in ["gzip", "gz"]: - mode = "w:gz" + mode = "w|gz" elif compression in ["bzip2", "bz2"]: - mode = "w:bz2" + mode = "w|bz2" elif compression in ["lzma", "xz"]: - mode = "w:xz" - else: - mode = "w" + mode = "w|xz" tar_buffer = io.BytesIO() remaining_size = uncompressed_size