Repository: lucianopaz/compress_pickle

Issue:
File ending with `.pkl.gz` is stored as `.pklgz`
Hello @lucianopaz,

Thank you for making this library!

I wanted to ask why, if the provided path is `.pkl.gz`, the files are stored as `.pklgz`.
This feels like an undesired default behaviour that may be, if necessary, enabled with a flag, as it breaks libraries that depend on the files to be stored as the given path requires.

Ciao e Grazie,
Luca

Discussion:

Patch:
diff --git a/compress_pickle/__init__.py b/compress_pickle/__init__.py
index a9221a9..1471ef4 100644
--- a/compress_pickle/__init__.py
+++ b/compress_pickle/__init__.py
@@ -4,4 +4,4 @@ from . import compressers
 from . import picklers
 from . import io
 
-__version__ = "2.0.0"
+__version__ = "2.0.1"
diff --git a/compress_pickle/utils.py b/compress_pickle/utils.py
index f172d63..4e226ad 100644
--- a/compress_pickle/utils.py
+++ b/compress_pickle/utils.py
@@ -135,4 +135,4 @@ def _infer_compression_from_path(path: PathType) -> Optional[str]:
 
 def _set_default_extension(path: PathType, compression: Optional[str]) -> str:
     root, current_ext = splitext(_stringyfy_path(path))
-    return root + get_default_compression_mapping()[compression]
+    return root + "." + get_default_compression_mapping()[compression]


Test patch:
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 8b54c9e..6ec6fcc 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -1,6 +1,12 @@
 import pytest
 import io
-from compress_pickle.utils import _stringyfy_path, _infer_compression_from_path
+from os.path import splitext
+from compress_pickle.compressers.registry import get_default_compression_mapping
+from compress_pickle.utils import (
+    _stringyfy_path,
+    _infer_compression_from_path,
+    _set_default_extension,
+)
 
 
 def test_stringify_path():
@@ -10,6 +16,17 @@ def test_stringify_path():
         _stringyfy_path({"a"})
 
 
+@pytest.mark.usefixtures("compressions")
+def test_set_default_extension(compressions):
+    root = "somepath.someotherstuff"
+    path = root + ".ext"
+    new_path = _set_default_extension(path, compression=compressions)
+    assert splitext(new_path) == (
+        root,
+        "." + get_default_compression_mapping()[compressions],
+    )
+
+
 @pytest.mark.usefixtures("valid_extensions")
 def test_infer_compression_from_path(valid_extensions):
     extension, compression = valid_extensions