Support Writeable Zipfile on workbook.save (#13009)

This commit is contained in:
Preethi
2024-11-13 15:45:49 +00:00
committed by GitHub
parent af4df4eb24
commit 51d0f0194c
2 changed files with 4 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
from _typeshed import StrPath, SupportsRead
from _typeshed import StrPath, SupportsRead, SupportsWrite
from typing import IO, Literal, Protocol
from typing_extensions import TypeAlias
@@ -25,6 +25,7 @@ _VisibilityType: TypeAlias = Literal["visible", "hidden", "veryHidden"] # noqa:
# TODO: Use a proper protocol from ZipFile. See: #10880
# This alias is to minimize false-positives
_ZipFileFileProtocol: TypeAlias = StrPath | IO[bytes] | SupportsRead[bytes] # noqa: Y047
_ZipFileFileWriteProtocol: TypeAlias = StrPath | IO[bytes] | SupportsWrite[bytes] # noqa: Y047
class _Decodable(Protocol): # noqa: Y046
def decode(self, encoding: str, /) -> str: ...

View File

@@ -5,7 +5,7 @@ from typing import Any, Final, type_check_only
from typing_extensions import TypeAlias, deprecated
from zipfile import ZipFile
from openpyxl import _Decodable, _ZipFileFileProtocol
from openpyxl import _Decodable, _ZipFileFileWriteProtocol
from openpyxl.chartsheet.chartsheet import Chartsheet
from openpyxl.styles.named_styles import NamedStyle
from openpyxl.utils.indexed_list import IndexedList
@@ -112,7 +112,7 @@ class Workbook:
def named_styles(self) -> list[str]: ...
@property
def mime_type(self) -> str: ...
def save(self, filename: _ZipFileFileProtocol) -> None: ...
def save(self, filename: _ZipFileFileWriteProtocol) -> None: ...
@property
def style_names(self) -> list[str]: ...
# A write_only and read_only workbooks can't use this method as it requires both reading and writing.