mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-08 20:43:25 +08:00
openpyxl: Make common alias for visibility literal string union (#10562)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from typing import Protocol
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from openpyxl.compat.numbers import NUMPY as NUMPY
|
||||
from openpyxl.reader.excel import load_workbook as load_workbook
|
||||
@@ -18,5 +19,7 @@ DEBUG: bool
|
||||
open = load_workbook
|
||||
|
||||
# Utility types reused elsewhere
|
||||
_VisibilityType: TypeAlias = Literal["visible", "hidden", "veryHidden"] # noqa: Y047
|
||||
|
||||
class _Decodable(Protocol): # noqa: Y046
|
||||
def decode(self, __encoding: str) -> str: ...
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from _typeshed import Incomplete, Unused
|
||||
from typing import ClassVar
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
from typing_extensions import Literal
|
||||
|
||||
from openpyxl import _Decodable
|
||||
from openpyxl import _Decodable, _VisibilityType
|
||||
from openpyxl.chartsheet.custom import CustomChartsheetViews
|
||||
from openpyxl.chartsheet.properties import ChartsheetProperties
|
||||
from openpyxl.chartsheet.protection import ChartsheetProtection
|
||||
@@ -17,8 +17,6 @@ from openpyxl.worksheet.drawing import Drawing
|
||||
from openpyxl.worksheet.header_footer import HeaderFooter as _HeaderFooter
|
||||
from openpyxl.worksheet.page import PageMargins, PrintPageSetup
|
||||
|
||||
_ChartsheetSheetState: TypeAlias = Literal["visible", "hidden", "veryHidden"]
|
||||
|
||||
class Chartsheet(_WorkbookChild, Serialisable):
|
||||
tagname: ClassVar[str]
|
||||
mime_type: str
|
||||
@@ -33,7 +31,7 @@ class Chartsheet(_WorkbookChild, Serialisable):
|
||||
picture: Typed[SheetBackgroundPicture, Literal[True]]
|
||||
webPublishItems: Typed[WebPublishItems, Literal[True]]
|
||||
extLst: Typed[ExtensionList, Literal[True]]
|
||||
sheet_state: Set[_ChartsheetSheetState]
|
||||
sheet_state: Set[_VisibilityType]
|
||||
headerFooter: Typed[_HeaderFooter, Literal[False]]
|
||||
HeaderFooter: Alias
|
||||
__elements__: ClassVar[tuple[str, ...]]
|
||||
@@ -54,7 +52,7 @@ class Chartsheet(_WorkbookChild, Serialisable):
|
||||
extLst: Unused = None,
|
||||
parent: Incomplete | None = None,
|
||||
title: str | _Decodable | None = "",
|
||||
sheet_state: _ChartsheetSheetState = "visible",
|
||||
sheet_state: _VisibilityType = "visible",
|
||||
) -> None: ...
|
||||
def add_chart(self, chart) -> None: ...
|
||||
def to_tree(self): ...
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
from _typeshed import Incomplete
|
||||
from typing import ClassVar, overload
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
from typing_extensions import Literal
|
||||
|
||||
from openpyxl import _VisibilityType
|
||||
from openpyxl.descriptors.base import Bool, Integer, Set, Typed, _ConvertibleToBool, _ConvertibleToInt
|
||||
from openpyxl.descriptors.serialisable import Serialisable
|
||||
from openpyxl.worksheet.header_footer import HeaderFooter
|
||||
from openpyxl.worksheet.page import PageMargins, PrintPageSetup
|
||||
|
||||
_CustomChartsheetViewState: TypeAlias = Literal["visible", "hidden", "veryHidden"]
|
||||
|
||||
class CustomChartsheetView(Serialisable):
|
||||
tagname: ClassVar[str]
|
||||
guid: Incomplete
|
||||
scale: Integer[Literal[False]]
|
||||
state: Set[_CustomChartsheetViewState]
|
||||
state: Set[_VisibilityType]
|
||||
zoomToFit: Bool[Literal[True]]
|
||||
pageMargins: Typed[PageMargins, Literal[True]]
|
||||
pageSetup: Typed[PrintPageSetup, Literal[True]]
|
||||
@@ -25,7 +24,7 @@ class CustomChartsheetView(Serialisable):
|
||||
guid: Incomplete | None = None,
|
||||
*,
|
||||
scale: _ConvertibleToInt,
|
||||
state: _CustomChartsheetViewState = "visible",
|
||||
state: _VisibilityType = "visible",
|
||||
zoomToFit: _ConvertibleToBool | None = None,
|
||||
pageMargins: PageMargins | None = None,
|
||||
pageSetup: PrintPageSetup | None = None,
|
||||
@@ -36,7 +35,7 @@ class CustomChartsheetView(Serialisable):
|
||||
self,
|
||||
guid: Incomplete | None,
|
||||
scale: _ConvertibleToInt,
|
||||
state: _CustomChartsheetViewState = "visible",
|
||||
state: _VisibilityType = "visible",
|
||||
zoomToFit: _ConvertibleToBool | None = None,
|
||||
pageMargins: PageMargins | None = None,
|
||||
pageSetup: PrintPageSetup | None = None,
|
||||
|
||||
@@ -2,6 +2,7 @@ from _typeshed import Incomplete, Unused
|
||||
from typing import ClassVar
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from openpyxl import _VisibilityType
|
||||
from openpyxl.descriptors.base import Alias, Bool, Integer, NoneSet, String, Typed, _ConvertibleToBool, _ConvertibleToInt
|
||||
from openpyxl.descriptors.excel import ExtensionList
|
||||
from openpyxl.descriptors.nested import NestedString
|
||||
@@ -13,7 +14,6 @@ from openpyxl.workbook.protection import FileSharing, WorkbookProtection
|
||||
from openpyxl.workbook.smart_tags import SmartTagList, SmartTagProperties
|
||||
from openpyxl.workbook.web import WebPublishing, WebPublishObjectList
|
||||
|
||||
_ChildSheetState: TypeAlias = Literal["visible", "hidden", "veryHidden"]
|
||||
_WorkbookPackageConformance: TypeAlias = Literal["strict", "transitional"]
|
||||
|
||||
class FileRecoveryProperties(Serialisable):
|
||||
@@ -34,13 +34,13 @@ class ChildSheet(Serialisable):
|
||||
tagname: ClassVar[str]
|
||||
name: String[Literal[False]]
|
||||
sheetId: Integer[Literal[False]]
|
||||
state: NoneSet[_ChildSheetState]
|
||||
state: NoneSet[_VisibilityType]
|
||||
id: Incomplete
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
sheetId: _ConvertibleToInt,
|
||||
state: _ChildSheetState | Literal["none"] | None = "visible",
|
||||
state: _VisibilityType | Literal["none"] | None = "visible",
|
||||
id: Incomplete | None = None,
|
||||
) -> None: ...
|
||||
|
||||
|
||||
@@ -2,17 +2,17 @@ from _typeshed import Incomplete, Unused
|
||||
from typing import ClassVar, overload
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from openpyxl import _VisibilityType
|
||||
from openpyxl.descriptors.base import Bool, Integer, NoneSet, String, Typed, _ConvertibleToBool, _ConvertibleToInt
|
||||
from openpyxl.descriptors.excel import ExtensionList
|
||||
from openpyxl.descriptors.serialisable import Serialisable
|
||||
|
||||
_BookViewVilibility: TypeAlias = Literal["visible", "hidden", "veryHidden"]
|
||||
_CustomWorkbookViewShowComments: TypeAlias = Literal["commNone", "commIndicator", "commIndAndComment"]
|
||||
_CustomWorkbookViewShowObjects: TypeAlias = Literal["all", "placeholders"]
|
||||
|
||||
class BookView(Serialisable):
|
||||
tagname: ClassVar[str]
|
||||
visibility: NoneSet[_BookViewVilibility]
|
||||
visibility: NoneSet[_VisibilityType]
|
||||
minimized: Bool[Literal[True]]
|
||||
showHorizontalScroll: Bool[Literal[True]]
|
||||
showVerticalScroll: Bool[Literal[True]]
|
||||
@@ -29,7 +29,7 @@ class BookView(Serialisable):
|
||||
__elements__: ClassVar[tuple[str, ...]]
|
||||
def __init__(
|
||||
self,
|
||||
visibility: _BookViewVilibility | Literal["none"] | None = "visible",
|
||||
visibility: _VisibilityType | Literal["none"] | None = "visible",
|
||||
minimized: _ConvertibleToBool | None = False,
|
||||
showHorizontalScroll: _ConvertibleToBool | None = True,
|
||||
showVerticalScroll: _ConvertibleToBool | None = True,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from _typeshed import Incomplete
|
||||
|
||||
from openpyxl import _VisibilityType
|
||||
from openpyxl.worksheet.worksheet import Worksheet
|
||||
|
||||
def read_dimension(source): ...
|
||||
@@ -15,7 +16,7 @@ class ReadOnlyWorksheet:
|
||||
__iter__ = Worksheet.__iter__
|
||||
parent: Incomplete
|
||||
title: str
|
||||
sheet_state: str
|
||||
sheet_state: _VisibilityType
|
||||
def __init__(self, parent_workbook, title: str, worksheet_path, shared_strings) -> None: ...
|
||||
def calculate_dimension(self, force: bool = False): ...
|
||||
def reset_dimensions(self) -> None: ...
|
||||
|
||||
@@ -4,7 +4,7 @@ from datetime import datetime
|
||||
from typing import Any, overload
|
||||
from typing_extensions import Final, Literal
|
||||
|
||||
from openpyxl import _Decodable
|
||||
from openpyxl import _Decodable, _VisibilityType
|
||||
from openpyxl.cell.cell import Cell, _CellValue
|
||||
from openpyxl.formatting.formatting import ConditionalFormattingList
|
||||
from openpyxl.workbook.child import _WorkbookChild
|
||||
@@ -53,7 +53,7 @@ class Worksheet(_WorkbookChild):
|
||||
col_breaks: ColBreak
|
||||
merged_cells: MultiCellRange
|
||||
data_validations: DataValidationList
|
||||
sheet_state: Literal["visible", "hidden", "veryHidden"]
|
||||
sheet_state: _VisibilityType
|
||||
page_setup: PrintPageSetup
|
||||
print_options: PrintOptions
|
||||
page_margins: PageMargins
|
||||
|
||||
Reference in New Issue
Block a user