Skip to content

Commit

Permalink
openpyxl: Various minor improvements / previous PR fixes (#10896)
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Oct 16, 2023
1 parent 9c0f435 commit 5e13bc0
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 21 deletions.
7 changes: 4 additions & 3 deletions stubs/openpyxl/openpyxl/cell/cell.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ from _typeshed import ReadableBuffer
from datetime import datetime
from re import Pattern
from typing import overload
from typing_extensions import Final
from typing_extensions import Final, Literal

from openpyxl.cell import _CellValue, _TimeTypes
from openpyxl.comments.comments import Comment
from openpyxl.compat.numbers import NUMERIC_TYPES as NUMERIC_TYPES # cell numeric types
from openpyxl.styles.cell_style import StyleArray
from openpyxl.styles.styleable import StyleableObject
from openpyxl.worksheet.hyperlink import Hyperlink
Expand All @@ -31,8 +32,8 @@ TYPE_FORMULA_CACHE_STRING: Final = "str"

VALID_TYPES: Final[tuple[str, ...]]

def get_type(t: type, value: object) -> str | None: ...
def get_time_format(t: datetime) -> str: ...
def get_type(t: type, value: object) -> Literal["n", "s", "d", "f", None]: ...
def get_time_format(t: _TimeTypes) -> str: ...

class Cell(StyleableObject):
row: int
Expand Down
2 changes: 1 addition & 1 deletion stubs/openpyxl/openpyxl/chart/label.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ from openpyxl.chart.text import RichText
from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToBool, _ConvertibleToInt
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.nested import NestedBool, NestedInteger, NestedNoneSet, NestedString, _NestedNoneSetParam
from openpyxl.descriptors.serialisable import Serialisable as Serialisable
from openpyxl.descriptors.serialisable import Serialisable

from ..xml._functions_overloads import _HasTagAndGet

Expand Down
2 changes: 1 addition & 1 deletion stubs/openpyxl/openpyxl/chartsheet/properties.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from typing import ClassVar
from typing_extensions import Literal

from openpyxl.descriptors.base import Bool, String, Typed, _ConvertibleToBool
from openpyxl.descriptors.serialisable import Serialisable as Serialisable
from openpyxl.descriptors.serialisable import Serialisable
from openpyxl.styles.colors import Color

class ChartsheetProperties(Serialisable):
Expand Down
4 changes: 2 additions & 2 deletions stubs/openpyxl/openpyxl/descriptors/sequence.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from _typeshed import Incomplete, Unused
from collections.abc import Generator, Iterable
from typing import Any, Protocol
from typing_extensions import Self, TypeVar
from typing import Any, Protocol, TypeVar
from typing_extensions import Self

from openpyxl.descriptors import Strict
from openpyxl.descriptors.serialisable import Serialisable, _SerialisableTreeElement
Expand Down
6 changes: 3 additions & 3 deletions stubs/openpyxl/openpyxl/styles/alignment.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from _typeshed import Incomplete
from collections.abc import Iterator
from typing import ClassVar
from typing_extensions import Literal, TypeAlias
from typing_extensions import Final, Literal, TypeAlias

from openpyxl.descriptors.base import Alias, Bool, Min, MinMax, NoneSet, _ConvertibleToBool, _ConvertibleToFloat
from openpyxl.descriptors.serialisable import Serialisable
Expand All @@ -11,8 +11,8 @@ _HorizontalAlignmentsType: TypeAlias = Literal[
]
_VerticalAlignmentsType: TypeAlias = Literal["top", "center", "bottom", "justify", "distributed"]

horizontal_alignments: tuple[_HorizontalAlignmentsType, ...]
vertical_aligments: tuple[_VerticalAlignmentsType, ...]
horizontal_alignments: Final[tuple[_HorizontalAlignmentsType, ...]]
vertical_aligments: Final[tuple[_VerticalAlignmentsType, ...]]

class Alignment(Serialisable):
tagname: ClassVar[str]
Expand Down
7 changes: 3 additions & 4 deletions stubs/openpyxl/openpyxl/styles/fills.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from collections.abc import Iterable, Iterator, Sequence as ABCSequence
from typing import ClassVar
from typing_extensions import Final, Literal, TypeAlias

from openpyxl.descriptors import Sequence
from openpyxl.descriptors import Sequence, Strict
from openpyxl.descriptors.base import Alias, Float, MinMax, NoneSet, Set, _ConvertibleToFloat
from openpyxl.descriptors.serialisable import Serialisable
from openpyxl.styles.colors import Color, ColorDescriptor
Expand Down Expand Up @@ -32,7 +32,6 @@ FILL_PATTERN_MEDIUMGRAY: Final = "mediumGray"

_GradientFillType: TypeAlias = Literal["linear", "path"]
_FillsType: TypeAlias = Literal[
"none",
"solid",
"darkDown",
"darkGray",
Expand All @@ -52,7 +51,7 @@ _FillsType: TypeAlias = Literal[
"lightVertical",
"mediumGray",
]
fills: tuple[_FillsType, ...]
fills: Final[tuple[_FillsType, ...]]

class Fill(Serialisable):
tagname: ClassVar[str]
Expand Down Expand Up @@ -90,7 +89,7 @@ class Stop(Serialisable):

class StopList(Sequence):
expected_type: type[Incomplete]
def __set__(self, obj, values) -> None: ...
def __set__(self, obj: Serialisable | Strict, values) -> None: ...

class GradientFill(Fill):
tagname: ClassVar[str]
Expand Down
9 changes: 5 additions & 4 deletions stubs/openpyxl/openpyxl/styles/protection.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from _typeshed import Incomplete
from typing import ClassVar
from typing_extensions import Literal

from openpyxl.descriptors.base import Bool, _ConvertibleToBool
from openpyxl.descriptors.serialisable import Serialisable

class Protection(Serialisable):
tagname: ClassVar[str]
locked: Incomplete
hidden: Incomplete
def __init__(self, locked: bool = True, hidden: bool = False) -> None: ...
locked: Bool[Literal[False]]
hidden: Bool[Literal[False]]
def __init__(self, locked: _ConvertibleToBool = True, hidden: _ConvertibleToBool = False) -> None: ...
6 changes: 3 additions & 3 deletions stubs/openpyxl/openpyxl/worksheet/_reader.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime
from _typeshed import Incomplete
from collections.abc import Container, Generator
from datetime import datetime
from typing_extensions import Final

from openpyxl.cell.rich_text import CellRichText
Expand Down Expand Up @@ -45,7 +45,7 @@ def parse_richtext_string(element: _ChildSerialisableTreeElement) -> CellRichTex
class WorkSheetParser:
min_row: Incomplete | None
min_col: Incomplete | None
epoch: datetime.datetime
epoch: datetime
source: Incomplete
shared_strings: Incomplete
data_only: bool
Expand Down Expand Up @@ -73,7 +73,7 @@ class WorkSheetParser:
src,
shared_strings,
data_only: bool = False,
epoch: datetime.datetime = ...,
epoch: datetime = ...,
date_formats: Container[Incomplete] = ...,
timedelta_formats: Container[Incomplete] = ...,
rich_text: bool = False,
Expand Down

0 comments on commit 5e13bc0

Please sign in to comment.