Skip to content

Commit

Permalink
Drop Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
hattya committed Oct 16, 2024
1 parent e507556 commit f86b12f
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 25 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jobs:
- macOS
- Windows
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
ZopfliPy Changelog
==================

Version 1.11
------------

* Drop Python 3.8 support.


Version 1.10
------------

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Installation
Requirements
------------

- Python 3.8+
- Python 3.9+


Usage
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ classifiers = [
"Programming Language :: C",
"Programming Language :: C++",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: System :: Archiving :: Compression",
]
requires-python = ">= 3.8"
requires-python = ">= 3.9"
dynamic = [
"version",
]
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
minversion = 3.3
envlist = py38, py39, py310, py311, py312
envlist = py39, py310, py311, py312
isolated_build = True

[testenv]
Expand Down
24 changes: 7 additions & 17 deletions zopfli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# zopfli
#
# Copyright (c) 2015-2023 Akinori Hattori <hattya@gmail.com>
# Copyright (c) 2015-2024 Akinori Hattori <hattya@gmail.com>
#
# SPDX-License-Identifier: Apache-2.0
#
Expand All @@ -14,7 +14,7 @@
import struct
import sys
import threading
from typing import TYPE_CHECKING, cast, Any, AnyStr, IO, Literal, Optional, Tuple, Union
from typing import cast, Any, AnyStr, IO, Literal, Optional, Union
import zipfile
import zlib

Expand All @@ -31,11 +31,7 @@
except ImportError:
__version__ = 'unknown'

if (TYPE_CHECKING
or sys.version_info >= (3, 9)):
P = Union[str, os.PathLike[str]]
else:
P = Union[str, os.PathLike]
P = Union[str, os.PathLike[str]]


class ZopfliDecompressor:
Expand Down Expand Up @@ -101,9 +97,7 @@ def open(self, name: Union[str, zipfile.ZipInfo], mode: Literal['r', 'w'] = 'r',
if (mode == 'w'
and self._zopflify(None)
and fp._compressor):
opts = self._options.copy()
opts.update(kwargs)
fp._compressor = ZopfliCompressor(ZOPFLI_FORMAT_DEFLATE, **opts)
fp._compressor = ZopfliCompressor(ZOPFLI_FORMAT_DEFLATE, **self._options | kwargs)
return fp

def _open_to_write(self, zinfo: zipfile.ZipInfo, force_zip64: bool = False) -> IO[bytes]:
Expand All @@ -115,9 +109,7 @@ def write(self, filename: P, arcname: Optional[P] = None,
z: Optional[ZopfliCompressor] = None
if zopflify:
compress_type = zipfile.ZIP_STORED
opts = self._options.copy()
opts.update(kwargs)
z = ZopfliCompressor(ZOPFLI_FORMAT_DEFLATE, **opts)
z = ZopfliCompressor(ZOPFLI_FORMAT_DEFLATE, **self._options | kwargs)
with self._lock:
fp = self.fp
try:
Expand Down Expand Up @@ -147,9 +139,7 @@ def writestr(self, zinfo_or_arcname: Union[str, zipfile.ZipInfo], data: AnyStr,
z: Optional[ZopfliCompressor] = None
if zopflify:
compress_type = zipfile.ZIP_STORED
opts = self._options.copy()
opts.update(kwargs)
z = ZopfliCompressor(ZOPFLI_FORMAT_DEFLATE, **opts)
z = ZopfliCompressor(ZOPFLI_FORMAT_DEFLATE, **self._options | kwargs)
with self._lock:
fp = self.fp
try:
Expand Down Expand Up @@ -268,7 +258,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
self.encoding = None

def _encodeFilenameFlags(self) -> Tuple[bytes, int]:
def _encodeFilenameFlags(self) -> tuple[bytes, int]:
if isinstance(self.filename, bytes):
return self.filename, self.flag_bits
encoding = codecs.lookup(self.encoding).name if self.encoding else 'ascii'
Expand Down
7 changes: 4 additions & 3 deletions zopfli/_zopfli.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#
# zopfli._zopfli
#
# Copyright (c) 2021 Akinori Hattori <hattya@gmail.com>
# Copyright (c) 2021-2024 Akinori Hattori <hattya@gmail.com>
#
# SPDX-License-Identifier: MIT
#

from typing import Optional, Sequence, Tuple
from collections.abc import Sequence
from typing import Optional


ZOPFLI_FORMAT_GZIP: int
Expand Down Expand Up @@ -38,7 +39,7 @@ class ZopfliPNG:
filter_strategies: str
auto_filter_strategy: bool
keep_color_type: bool
keep_chunks: Tuple[str, ...]
keep_chunks: tuple[str, ...]
use_zopfli: bool
iterations: int
iterations_large: int
Expand Down

0 comments on commit f86b12f

Please sign in to comment.