Skip to content

Commit

Permalink
core: add zstd as optional dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
karlicoss committed Oct 10, 2023
1 parent ff69aaf commit 63a4b03
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ testing = [
"mypy",
"lxml", # for mypy html coverage
]
zstd = [
"zstandard",
]


[build-system]
Expand Down
4 changes: 2 additions & 2 deletions src/kompress/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ def is_compressed(p: PathIsh) -> bool:


def _zstd_open(path: Path, *args, **kwargs) -> IO:
import zstandard as zstd # type: ignore
import zstandard

fh = path.open('rb')
dctx = zstd.ZstdDecompressor()
dctx = zstandard.ZstdDecompressor()
reader = dctx.stream_reader(fh)

mode = kwargs.get('mode', 'rt')
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ commands =

[testenv:mypy]
commands =
{envpython} -m pip install --use-pep517 -e .[testing]
{envpython} -m pip install --use-pep517 -e .[testing,zstd]
{envpython} -m mypy --install-types --non-interactive \
-p {[testenv]package_name} \
# txt report is a bit more convenient to view on CI
Expand Down

0 comments on commit 63a4b03

Please sign in to comment.