Skip to content

Commit

Permalink
Explicit re-exports
Browse files Browse the repository at this point in the history
  • Loading branch information
aMarcireau committed Nov 24, 2022
1 parent ab8ae52 commit c384142
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
24 changes: 22 additions & 2 deletions source/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
from .lzip import *
from .version import *
from .lzip import (
default_level as default_level,
default_word_size as default_word_size,
default_chunk_size as default_chunk_size,
default_member_size as default_member_size,
level_to_dictionary_size_and_match_len_limit as level_to_dictionary_size_and_match_len_limit,
RemainingBytesError as RemainingBytesError,
decompress_file_like_iter as decompress_file_like_iter,
decompress_file_like as decompress_file_like,
decompress_file_iter as decompress_file_iter,
decompress_file as decompress_file,
decompress_buffer_iter as decompress_buffer_iter,
decompress_buffer as decompress_buffer,
decompress_url_iter as decompress_url_iter,
decompress_url as decompress_url,
BufferEncoder as BufferEncoder,
compress_to_buffer as compress_to_buffer,
FileEncoder as FileEncoder,
compress_to_file as compress_to_file,
)

from .version import __version__ as __version__, __lzlib_version__ as __lzlib_version__
13 changes: 7 additions & 6 deletions source/lzip.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def decompress_url_iter(
chunk_size=None,
):
if timeout is None:
timeout = socket._GLOBAL_DEFAULT_TIMEOUT
timeout = socket._GLOBAL_DEFAULT_TIMEOUT # type: ignore
with urllib.request.urlopen(
url, data, timeout, cafile=cafile, capath=capath, context=context
) as response:
Expand All @@ -111,7 +111,7 @@ def decompress_url(
chunk_size=None,
) -> bytes:
if timeout is None:
timeout = socket._GLOBAL_DEFAULT_TIMEOUT
timeout = socket._GLOBAL_DEFAULT_TIMEOUT # type: ignore
with urllib.request.urlopen(
url, data, timeout, cafile=cafile, capath=capath, context=context
) as response:
Expand All @@ -132,6 +132,7 @@ def __init__(
else:
assert level >= 0 and level < 10
level = level_to_dictionary_size_and_match_len_limit[level]
assert isinstance(level, (list, tuple))
assert (
isinstance(level[0], int) and level[0] >= (1 << 12) and level[0] < (1 << 29)
)
Expand All @@ -144,7 +145,7 @@ def __init__(
)

def compress(self, buffer: bytes) -> None:
return self.encoder.compress(buffer)
return self.encoder.compress(buffer) # type: ignore

def finish(self) -> bytes:
result = self.encoder.finish()
Expand All @@ -159,7 +160,7 @@ def compress_to_buffer(
level = default_level
encoder = BufferEncoder(level, member_size)
result = encoder.compress(buffer)
result += encoder.finish()
result += encoder.finish() # type: ignore
return result


Expand Down Expand Up @@ -192,10 +193,10 @@ def __init__(
self.file = open(path, "wb")

def compress(self, buffer: bytes) -> None:
self.file.write(self.encoder.compress(buffer))
self.file.write(self.encoder.compress(buffer)) # type: ignore

def close(self) -> None:
self.file.write(self.encoder.finish())
self.file.write(self.encoder.finish()) # type: ignore
self.encoder = None
self.file.close()
self.file = None
Expand Down

0 comments on commit c384142

Please sign in to comment.