Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge openpyxl stubs from microsoft/python-type-stubs #9511

Draft
wants to merge 98 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
e371358
Bring openpyxl stubs at least up to par with microsoft/python-type-stubs
Avasam Jan 10, 2023
f47d473
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Jan 11, 2023
e08d3ea
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Jan 12, 2023
9c14076
Include numpy
Avasam Jan 12, 2023
4e7fc09
Convertible Descriptors
Avasam Jan 12, 2023
8a9de85
Update after self-review
Avasam Jan 12, 2023
704399f
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Feb 8, 2023
dd5a152
Update tests
Avasam Feb 8, 2023
f11292d
Fix pytype errors
Avasam Feb 9, 2023
e3419bd
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Feb 21, 2023
7b034b2
Fixes
Avasam Feb 21, 2023
674f8ff
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Feb 23, 2023
093b061
PR comments
Avasam Feb 23, 2023
ba82470
quick CI fixes
Avasam Feb 23, 2023
9e63d21
failed at version checking
Avasam Feb 23, 2023
d1e618e
Apply suggestions from code review
Avasam Feb 28, 2023
6d6d1ce
Add alias _UnderlineType and update Self
Avasam Feb 28, 2023
567a1a8
Merge branch 'openpyxl-from-microsoft-python-type-stubs' of https://g…
Avasam Feb 28, 2023
12789fe
Post-merge fixes
Avasam Feb 28, 2023
bfb6c60
Make stubuploader tests pass
Avasam Feb 28, 2023
2a98afc
Merge branch 'main' into openpyxl-from-microsoft-python-type-stubs
AlexWaygood Mar 16, 2023
f5df850
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 16, 2023
028ac1c
Apply suggestions from code review
AlexWaygood Mar 16, 2023
6bdc7df
Update stubs/openpyxl/openpyxl/reader/workbook.pyi
AlexWaygood Mar 16, 2023
e5e4eb3
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Mar 22, 2023
7b9ccae
Merge branch 'main' into openpyxl-from-microsoft-python-type-stubs
srittau Mar 24, 2023
c7c24e8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 24, 2023
368a500
Merge branch 'openpyxl-from-microsoft-python-type-stubs' of https://g…
Avasam Mar 31, 2023
ed09fc2
Run stubdefaulter
Avasam Mar 31, 2023
b5fd48c
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Mar 31, 2023
feef334
Use new type aliases for params
Avasam May 10, 2023
bc66516
Type MetaSerialisable dunders
Avasam May 10, 2023
4bfc8fb
Merge branch 'Type-MetaSerialisable-dunders' of https://github.com/Av…
Avasam May 10, 2023
4a050d9
regroup __init__ in stubtest_allowlist
Avasam May 10, 2023
93c9bfc
.
Avasam May 10, 2023
a1f40c6
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam May 20, 2023
2557483
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Jun 12, 2023
ff8e704
Type openpyxl incomplete dunders
Avasam Jun 12, 2023
ac138f8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 12, 2023
031592c
Remove redundant suppressions
Avasam Jun 12, 2023
d856a33
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Jun 13, 2023
328001b
Merge branch 'openpyxl-incomplete-dunders' of https://github.com/Avas…
Avasam Jun 13, 2023
82d17a6
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Jun 15, 2023
c127da3
Merge branch 'openpyxl-incomplete-dunders' of https://github.com/Avas…
Avasam Jun 15, 2023
6331d8a
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Jul 23, 2023
ce181aa
_SerialisableTreeElement
Avasam Jul 23, 2023
a4fff41
openpyxl: Class properties set explicitely as another class'
Avasam Aug 9, 2023
7b2180d
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Aug 11, 2023
dba0b8d
Merge branch 'openpyxl-Class-properties-set-explicitely' of https://g…
Avasam Aug 11, 2023
aac6860
Complete openpyxl title type annotations
Avasam Aug 11, 2023
79bd5fe
Merge branch 'openpyxl-title' of https://github.com/Avasam/typeshed i…
Avasam Aug 12, 2023
0ba3633
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Aug 15, 2023
50a27a8
Fixes post merge
Avasam Aug 18, 2023
8c43a40
Complete `from_tree`
Avasam Aug 18, 2023
f5cb6fe
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Aug 21, 2023
491efaf
Serialisable.from_tree improvement to avoid override issues
Avasam Aug 21, 2023
94c8b66
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Sep 12, 2023
a2e8d15
Type usages of PIL and zipfile
Avasam Sep 12, 2023
f08c6f1
Update stubtest_allowlist
Avasam Sep 12, 2023
29c9218
Update `get_rel`
Avasam Sep 12, 2023
c32f3e2
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Sep 19, 2023
a27c72f
Merge branch 'openpyxl-external-types' of https://github.com/Avasam/t…
Avasam Sep 19, 2023
5a284d6
Extract PIL and zipfile to #10706
Avasam Sep 19, 2023
200c096
datetime and _FileRead changes and fixes
Avasam Sep 19, 2023
9eb96b8
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Oct 13, 2023
d0793fc
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Oct 16, 2023
b957b79
Revert some import changes to reduce changes
Avasam Oct 16, 2023
ae8101c
Generator send actually unknown
Avasam Oct 16, 2023
6f408a6
avoid backref
Avasam Oct 16, 2023
11446be
tagname stays classvar
Avasam Oct 16, 2023
1f66b3f
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Nov 1, 2023
2fbb0e3
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Nov 2, 2023
5fc62cc
non-complex extraction from 9511
Avasam Dec 1, 2023
cc96eb4
Fix CI failures
Avasam Dec 1, 2023
169ea20
create_sheet return type
Avasam Dec 1, 2023
c0521d1
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Dec 1, 2023
d491dd8
Merge branch 'main' of https://github.com/python/typeshed into non-co…
Avasam Dec 1, 2023
a74c7ef
Post-merge fix missing Element
Avasam Dec 1, 2023
c272267
Merge branch 'non-complex-extraction-from-9511' of https://github.com…
Avasam Dec 1, 2023
17ff8a0
.
Avasam Dec 1, 2023
fd5a9a9
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Dec 4, 2023
333054d
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Dec 6, 2023
b35695d
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Mar 6, 2024
3b0034b
Update stubs/openpyxl/openpyxl/worksheet/_reader.pyi
Avasam Mar 6, 2024
6290b35
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Mar 11, 2024
08e4e91
Merge branch 'openpyxl-from-microsoft-python-type-stubs' of https://g…
Avasam Mar 11, 2024
a9021fc
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Mar 13, 2024
2bf8906
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Apr 1, 2024
8db96b3
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Apr 8, 2024
e2f2720
Merge branch 'main' into openpyxl-from-microsoft-python-type-stubs
Avasam Aug 18, 2024
2979638
Merge branch 'main' into openpyxl-from-microsoft-python-type-stubs
Avasam Sep 23, 2024
9cd6ffe
openpyxl: `Cell | MergedCell` annotations
Avasam Nov 25, 2024
82b5fcc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 25, 2024
e0d6119
lint fixes
Avasam Nov 25, 2024
f17d61c
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Nov 25, 2024
0b0b501
Rename _Cell to _CellOrMergedCell
Avasam Nov 25, 2024
1a6d68e
Merge branch 'openpyxl-Cell-or-MergedCell-annotations' of https://git…
Avasam Nov 25, 2024
3fe91a6
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Nov 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
429 changes: 428 additions & 1 deletion stubs/openpyxl/@tests/stubtest_allowlist.txt

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions stubs/openpyxl/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
version = "3.0.*"
requires = ["lxml-stubs", "types-pillow", "numpy"]

[tool.stubtest]
ignore_missing_stub = false
6 changes: 6 additions & 0 deletions stubs/openpyxl/openpyxl/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Protocol

from openpyxl.compat.numbers import NUMPY as NUMPY
from openpyxl.reader.excel import load_workbook as load_workbook
from openpyxl.workbook import Workbook as Workbook
Expand All @@ -13,3 +15,7 @@ from ._constants import (
)

open = load_workbook

# Utility type reused elsewhere
class _Decodable(Protocol): # noqa: Y046 # Utility type reused elsewhere
def decode(self, __encoding: str) -> str: ...
104 changes: 58 additions & 46 deletions stubs/openpyxl/openpyxl/cell/cell.pyi
Original file line number Diff line number Diff line change
@@ -1,78 +1,90 @@
from _typeshed import Incomplete
import datetime
from re import Pattern
from typing_extensions import Final, Literal, TypeAlias

from openpyxl.comments.comments import Comment
from openpyxl.compat.numbers import NUMERIC_TYPES as NUMERIC_TYPES, _NumericTypes
from openpyxl.styles.cell_style import StyleArray
from openpyxl.styles.styleable import StyleableObject
from openpyxl.workbook.child import _WorkbookChild
from openpyxl.worksheet.hyperlink import Hyperlink

__docformat__: str
TIME_TYPES: Incomplete
TIME_FORMATS: Incomplete
STRING_TYPES: Incomplete
KNOWN_TYPES: Incomplete
ILLEGAL_CHARACTERS_RE: Incomplete
ERROR_CODES: Incomplete
TYPE_STRING: str
TYPE_FORMULA: str
TYPE_NUMERIC: str
TYPE_BOOL: str
TYPE_NULL: str
TYPE_INLINE: str
TYPE_ERROR: str
TYPE_FORMULA_CACHE_STRING: str
VALID_TYPES: Incomplete
TIME_TYPES: tuple[type[datetime.datetime], type[datetime.date], type[datetime.time], type[datetime.timedelta]]
AlexWaygood marked this conversation as resolved.
Show resolved Hide resolved
_TimeTypes: TypeAlias = datetime.datetime | datetime.date | datetime.time | datetime.timedelta
TIME_FORMATS: dict[_TimeTypes, str]
Avasam marked this conversation as resolved.
Show resolved Hide resolved
STRING_TYPES: tuple[type[str], type[bytes]]
_StringTypes: TypeAlias = str | bytes
# mypy will simplify the type. Pyright fully expands it.
KNOWN_TYPES = NUMERIC_TYPES + TIME_TYPES + STRING_TYPES + (bool, type(None)) # noqa: F821,Y026
_KnownTypes: TypeAlias = _NumericTypes | _TimeTypes | _StringTypes | bool | None
ILLEGAL_CHARACTERS_RE: Pattern[str]
ERROR_CODES: Final = ("#NULL!", "#DIV/0!", "#VALUE!", "#REF!", "#NAME?", "#NUM!", "#N/A")
TYPE_STRING: Final = "s"
TYPE_FORMULA: Final = "f"
TYPE_NUMERIC: Final = "n"
TYPE_BOOL: Final = "b"
TYPE_NULL: Final = "n"
TYPE_INLINE: Final = "inlineStr"
TYPE_ERROR: Final = "e"
TYPE_FORMULA_CACHE_STRING: Final = "str"

def get_type(t, value): ...
def get_time_format(t): ...
VALID_TYPES = (TYPE_STRING, TYPE_FORMULA, TYPE_NUMERIC, TYPE_BOOL, TYPE_NULL, TYPE_INLINE, TYPE_ERROR, TYPE_FORMULA_CACHE_STRING)

def get_type(t, value) -> Literal["n", "s", "d", None]: ...
def get_time_format(t) -> str: ...

class Cell(StyleableObject):
row: Incomplete
column: Incomplete
row: int | None
column: int | None
data_type: str
def __init__(
self,
worksheet,
row: Incomplete | None = ...,
column: Incomplete | None = ...,
value: Incomplete | None = ...,
style_array: Incomplete | None = ...,
worksheet: _WorkbookChild,
row: int | None = ...,
column: int | None = ...,
value: _KnownTypes = ...,
style_array: StyleArray | None = ...,
) -> None: ...
@property
def coordinate(self): ...
def coordinate(self) -> str: ...
@property
def col_idx(self): ...
def col_idx(self) -> int: ...
@property
def column_letter(self): ...
def column_letter(self) -> str: ...
@property
def encoding(self): ...
def encoding(self) -> str: ...
@property
def base_date(self): ...
def check_string(self, value): ...
def check_string(self, value: str | bytes): ...
def check_error(self, value): ...
@property
def value(self): ...
def value(self) -> _KnownTypes: ...
@value.setter
def value(self, value) -> None: ...
def value(self, value: _KnownTypes) -> None: ...
@property
def internal_value(self): ...
def internal_value(self) -> _KnownTypes: ...
@property
def hyperlink(self): ...
def hyperlink(self) -> Hyperlink | None: ...
@hyperlink.setter
def hyperlink(self, val) -> None: ...
def hyperlink(self, val: Hyperlink | str | None) -> None: ...
@property
def is_date(self): ...
def is_date(self) -> bool: ...
def offset(self, row: int = ..., column: int = ...): ...
@property
def comment(self): ...
def comment(self) -> Comment | None: ...
@comment.setter
def comment(self, value) -> None: ...
def comment(self, value: Comment | None) -> None: ...

class MergedCell(StyleableObject):
data_type: str
comment: Incomplete
hyperlink: Incomplete
row: Incomplete
column: Incomplete
def __init__(self, worksheet, row: Incomplete | None = ..., column: Incomplete | None = ...) -> None: ...
comment: Comment | None
hyperlink: Hyperlink | None
row: int | None
column: int | None
def __init__(self, worksheet: _WorkbookChild, row: int | None = ..., column: int | None = ...) -> None: ...
@property
def coordinate(self): ...
value: Incomplete
def coordinate(self) -> str: ...
value: _KnownTypes

def WriteOnlyCell(ws: Incomplete | None = ..., value: Incomplete | None = ...): ...
def WriteOnlyCell(ws: _WorkbookChild | None = ..., value: _KnownTypes = ...) -> Cell: ...
125 changes: 67 additions & 58 deletions stubs/openpyxl/openpyxl/cell/text.pyi
Original file line number Diff line number Diff line change
@@ -1,82 +1,91 @@
from _typeshed import Incomplete
from typing_extensions import Literal, TypeAlias

from openpyxl.descriptors.base import _IntegerSetter
from openpyxl.descriptors.sequence import _Sequence
from openpyxl.descriptors.serialisable import Serialisable
from openpyxl.styles.colors import Color
from openpyxl.styles.fonts import Font

class PhoneticProperties(Serialisable):
tagname: str
fontId: Incomplete
type: Incomplete
alignment: Incomplete
@property
def fontId(self) -> int: ...
@fontId.setter
def fontId(self, __value: _IntegerSetter | None) -> None: ...
type: Literal["halfwidthKatakana", "fullwidthKatakana", "Hiragana", "noConversion", None]
alignment: Literal["noControl", "left", "center", "distributed", None]
def __init__(
self, fontId: Incomplete | None = ..., type: Incomplete | None = ..., alignment: Incomplete | None = ...
self,
fontId: _IntegerSetter,
type: Literal["halfwidthKatakana", "fullwidthKatakana", "Hiragana", "noConversion", None] = ...,
alignment: Literal["noControl", "left", "center", "distributed", None] = ...,
) -> None: ...

class PhoneticText(Serialisable):
tagname: str
sb: Incomplete
eb: Incomplete
t: Incomplete
text: Incomplete
def __init__(self, sb: Incomplete | None = ..., eb: Incomplete | None = ..., t: Incomplete | None = ...) -> None: ...
@property
def sb(self) -> int: ...
@sb.setter
def sb(self, __value: _IntegerSetter) -> None: ...
@property
def eb(self) -> int: ...
@eb.setter
def eb(self, __value: _IntegerSetter) -> None: ...
t: str
text = t # noqa: F821
def __init__(self, sb: _IntegerSetter, eb: _IntegerSetter, t: str) -> None: ...

class InlineFont(Font):
tagname: str
rFont: Incomplete
charset: Incomplete
family: Incomplete
b: Incomplete
i: Incomplete
strike: Incomplete
outline: Incomplete
shadow: Incomplete
condense: Incomplete
extend: Incomplete
color: Incomplete
sz: Incomplete
u: Incomplete
vertAlign: Incomplete
scheme: Incomplete
__elements__: Incomplete
rFont: str | None
__elements__: tuple[str, ...]
def __init__(
self,
rFont: Incomplete | None = ...,
charset: Incomplete | None = ...,
family: Incomplete | None = ...,
b: Incomplete | None = ...,
i: Incomplete | None = ...,
strike: Incomplete | None = ...,
outline: Incomplete | None = ...,
shadow: Incomplete | None = ...,
condense: Incomplete | None = ...,
extend: Incomplete | None = ...,
color: Incomplete | None = ...,
sz: Incomplete | None = ...,
u: Incomplete | None = ...,
vertAlign: Incomplete | None = ...,
scheme: Incomplete | None = ...,
rFont: str | None = ...,
charset: int | None = ...,
family: float | None = ...,
b: bool | None = ...,
i: bool | None = ...,
strike: bool | None = ...,
outline: bool | None = ...,
shadow: bool | None = ...,
condense: bool | None = ...,
extend: bool | None = ...,
color: Color | None = ...,
sz: float | None = ...,
u: Literal["single", "double", "singleAccounting", "doubleAccounting", None] = ...,
vertAlign: Literal["superscript", "subscript", "baseline", None] = ...,
scheme: Literal["major", "minor", None] = ...,
) -> None: ...

class RichText(Serialisable):
tagname: str
rPr: Incomplete
font: Incomplete
t: Incomplete
text: Incomplete
__elements__: Incomplete
def __init__(self, rPr: Incomplete | None = ..., t: Incomplete | None = ...) -> None: ...
rPr: InlineFont | None
font = rPr # noqa: F821
t: str | None
text = t # noqa: F821
__elements__: tuple[str, ...]
def __init__(self, rPr: InlineFont | None = ..., t: str | None = ...) -> None: ...

_PhoneticProperties: TypeAlias = PhoneticProperties

class Text(Serialisable):
tagname: str
t: Incomplete
plain: Incomplete
r: Incomplete
formatted: Incomplete
rPh: Incomplete
phonetic: Incomplete
phoneticPr: Incomplete
PhoneticProperties: Incomplete
__elements__: Incomplete
def __init__(self, t: Incomplete | None = ..., r=..., rPh=..., phoneticPr: Incomplete | None = ...) -> None: ...
t: str | None
plain = t # noqa: F821
r: _Sequence[RichText] | None
formatted = r # noqa: F821
rPh: _Sequence[PhoneticText] | None
phonetic = rPh # noqa: F821
phoneticPr: _PhoneticProperties | None
PhoneticProperties = phoneticPr # noqa: F821
__elements__: tuple[str, ...]
def __init__(
self,
t: str | None = ...,
r: _Sequence[RichText] | None = ...,
rPh: _Sequence[RichText] | None = ...,
phoneticPr: _PhoneticProperties | None = ...,
) -> None: ...
@property
def content(self): ...
def content(self) -> str: ...
Loading