-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add type stub for the lzma module #1844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
13143f8
Add type stub for the lzma module
PeterJCLaw 5e1726c
Claim to extend BinaryIO to resolve test failures
PeterJCLaw 0339a8f
Whitespace
PeterJCLaw a824afe
Filter chains can actually be any mapping
PeterJCLaw ff7fe24
Fix defaults for filename
PeterJCLaw 2ae4a6d
Remove redundant if and else
PeterJCLaw 444d0cc
Add overlooked exception class
PeterJCLaw cb0e8ac
Add overlooked function
PeterJCLaw fc4eb12
Filter chains can in fact be sequences
PeterJCLaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import io | ||
import sys | ||
from typing import Any, BinaryIO, IO, List, Mapping, Optional, Sequence, Union | ||
|
||
if sys.version_info >= (3, 6): | ||
from os import PathLike | ||
_PathOrFile = Union[str, bytes, IO[Any], PathLike[Any]] | ||
else: | ||
_PathOrFile = Union[str, bytes, IO[Any]] | ||
|
||
_FilterChain = Sequence[Mapping[str, Any]] | ||
|
||
FORMAT_AUTO: int | ||
FORMAT_XZ: int | ||
FORMAT_ALONE: int | ||
FORMAT_RAW: int | ||
CHECK_NONE: int | ||
CHECK_CRC32: int | ||
CHECK_CRC64: int | ||
CHECK_SHA256: int | ||
CHECK_ID_MAX: int | ||
CHECK_UNKNOWN: int | ||
FILTER_LZMA1: int | ||
FILTER_LZMA2: int | ||
FILTER_DELTA: int | ||
FILTER_X86: int | ||
FILTER_IA64: int | ||
FILTER_ARM: int | ||
FILTER_ARMTHUMB: int | ||
FILTER_SPARC: int | ||
FILTER_POWERPC: int | ||
MF_HC3: int | ||
MF_HC4: int | ||
MF_BT2: int | ||
MF_BT3: int | ||
MF_BT4: int | ||
MODE_FAST: int | ||
MODE_NORMAL: int | ||
PRESET_DEFAULT: int | ||
PRESET_EXTREME: int | ||
|
||
# from _lzma.c | ||
class LZMADecompressor(object): | ||
def __init__(self, format: Optional[int] = ..., memlimit: Optional[int] = ..., filters: Optional[_FilterChain] = ...) -> None: ... | ||
def decompress(self, data: bytes, max_length: int = ...) -> bytes: ... | ||
@property | ||
def check(self) -> int: ... | ||
@property | ||
def eof(self) -> bool: ... | ||
@property | ||
def unused_data(self) -> bytes: ... | ||
if sys.version_info >= (3, 5): | ||
@property | ||
def needs_input(self) -> bool: ... | ||
|
||
# from _lzma.c | ||
class LZMACompressor(object): | ||
def __init__(self, | ||
format: Optional[int] = ..., | ||
check: int = ..., | ||
preset: Optional[int] = ..., | ||
filters: Optional[_FilterChain] = ...) -> None: ... | ||
def compress(self, data: bytes) -> bytes: ... | ||
def flush(self) -> bytes: ... | ||
|
||
|
||
class LZMAError(Exception): ... | ||
|
||
|
||
class LZMAFile(BinaryIO): | ||
def __init__(self, | ||
filename: Optional[_PathOrFile] = ..., | ||
mode: str = ..., | ||
*, | ||
format: Optional[int] = ..., | ||
check: int = ..., | ||
preset: Optional[int] = ..., | ||
filters: Optional[_FilterChain] = ...) -> None: ... | ||
def close(self) -> None: ... | ||
@property | ||
def closed(self) -> bool: ... | ||
def fileno(self) -> int: ... | ||
def seekable(self) -> bool: ... | ||
def readable(self) -> bool: ... | ||
def writable(self) -> bool: ... | ||
def peek(self, size: int = ...) -> bytes: ... | ||
def read(self, size: int = ...) -> bytes: ... | ||
def read1(self, size: int = ...) -> bytes: ... | ||
def readline(self, size: int = ...) -> bytes: ... | ||
def write(self, data: bytes) -> int: ... | ||
def seek(self, offset: int, whence: int = ...) -> int: ... | ||
def tell(self) -> int: ... | ||
|
||
|
||
def open(filename: _PathOrFile, | ||
mode: str = ..., | ||
*, | ||
format: Optional[int] = ..., | ||
check: int = ..., | ||
preset: Optional[int] = ..., | ||
filters: Optional[_FilterChain] = ..., | ||
encoding: Optional[str] = ..., | ||
errors: Optional[str] = ..., | ||
newline: Optional[str] = ...) -> IO[Any]: ... | ||
def compress(data: bytes, format: int = ..., check: int = ..., preset: Optional[int] = ..., filters: Optional[_FilterChain] = ...) -> bytes: ... | ||
def decompress(data: bytes, format: int = ..., memlimit: Optional[int] = ..., filters: Optional[_FilterChain] = ...) -> bytes: ... | ||
def is_check_supported(check: int) -> bool: ... |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're missing
is_check_supported
from https://docs.python.org/3/library/lzma.html#miscellaneous, and the exception classLZMAError
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, 444d0cc and cb0e8ac add those.