Improve openpyxl annotations (#9764)

Co-authored-by: ArnabRollin <iamarnab.phukan@gmail.com>
Co-authored-by: ArnabRollin <106329283+ArnabRollin@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Mynhardt Burger
2023-02-21 10:36:57 -05:00
committed by GitHub
parent f2ae3542d3
commit 3f6f54e9d9
4 changed files with 234 additions and 137 deletions

View File

@@ -1,6 +1,11 @@
from _typeshed import Incomplete
from datetime import datetime
from openpyxl.comments.comments import Comment
from openpyxl.styles.cell_style import StyleArray
from openpyxl.styles.styleable import StyleableObject
from openpyxl.worksheet.hyperlink import Hyperlink
from openpyxl.worksheet.worksheet import Worksheet
__docformat__: str
TIME_TYPES: Incomplete
@@ -19,60 +24,60 @@ TYPE_ERROR: str
TYPE_FORMULA_CACHE_STRING: str
VALID_TYPES: Incomplete
def get_type(t, value): ...
def get_time_format(t): ...
def get_type(t: type, value: object) -> str | None: ...
def get_time_format(t: datetime) -> str: ...
class Cell(StyleableObject):
row: Incomplete
column: Incomplete
row: int
column: int
data_type: str
def __init__(
self,
worksheet,
row: Incomplete | None = ...,
column: Incomplete | None = ...,
value: Incomplete | None = ...,
style_array: Incomplete | None = ...,
worksheet: Worksheet,
row: int | None = ...,
column: int | None = ...,
value: str | float | datetime | None = ...,
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_error(self, value): ...
def base_date(self) -> datetime: ...
def check_string(self, value: str): ...
def check_error(self, value: object) -> str: ...
@property
def value(self): ...
def value(self) -> str | float | datetime | None: ...
@value.setter
def value(self, value) -> None: ...
def value(self, value: str | float | datetime | None) -> None: ...
@property
def internal_value(self): ...
def internal_value(self) -> str | float | datetime | None: ...
@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 offset(self, row: int = ..., column: int = ...): ...
def is_date(self) -> bool: ...
def offset(self, row: int = ..., column: int = ...) -> Cell: ...
@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
column: int
def __init__(self, worksheet: Worksheet, row: int | None = ..., column: int | None = ...) -> None: ...
@property
def coordinate(self): ...
value: Incomplete
def coordinate(self) -> str: ...
value: str | float | int | datetime | None
def WriteOnlyCell(ws: Incomplete | None = ..., value: Incomplete | None = ...): ...
def WriteOnlyCell(ws: Worksheet | None = ..., value: str | float | datetime | None = ...) -> Cell: ...

View File

@@ -1,4 +1,8 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, StrPath, SupportsRead
from openpyxl.chartsheet.chartsheet import Chartsheet
from openpyxl.packaging.relationship import Relationship
from openpyxl.workbook.workbook import Workbook
SUPPORTED_FORMATS: Incomplete
@@ -10,7 +14,9 @@ class ExcelReader:
data_only: Incomplete
keep_links: Incomplete
shared_strings: Incomplete
def __init__(self, fn, read_only: bool = ..., keep_vba=..., data_only: bool = ..., keep_links: bool = ...) -> None: ...
def __init__(
self, fn: SupportsRead[bytes] | str, read_only: bool = ..., keep_vba=..., data_only: bool = ..., keep_links: bool = ...
) -> None: ...
package: Incomplete
def read_manifest(self) -> None: ...
def read_strings(self) -> None: ...
@@ -19,8 +25,14 @@ class ExcelReader:
def read_workbook(self) -> None: ...
def read_properties(self) -> None: ...
def read_theme(self) -> None: ...
def read_chartsheet(self, sheet, rel) -> None: ...
def read_chartsheet(self, sheet: Chartsheet, rel: Relationship) -> None: ...
def read_worksheets(self) -> None: ...
def read(self) -> None: ...
def load_workbook(filename, read_only: bool = ..., keep_vba=..., data_only: bool = ..., keep_links: bool = ...): ...
def load_workbook(
filename: SupportsRead[bytes] | StrPath,
read_only: bool = ...,
keep_vba: bool = ...,
data_only: bool = ...,
keep_links: bool = ...,
) -> Workbook: ...

View File

@@ -1,4 +1,14 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, StrPath
from collections.abc import Iterator
from datetime import datetime
from typing import IO
from openpyxl.chartsheet.chartsheet import Chartsheet
from openpyxl.styles.named_styles import NamedStyle
from openpyxl.workbook.child import _WorkbookChild
from openpyxl.workbook.defined_name import DefinedName
from openpyxl.worksheet._write_only import WriteOnlyWorksheet
from openpyxl.worksheet.worksheet import Worksheet
INTEGER_TYPES: Incomplete
@@ -20,54 +30,54 @@ class Workbook:
views: Incomplete
def __init__(self, write_only: bool = ..., iso_dates: bool = ...) -> None: ...
@property
def epoch(self): ...
def epoch(self) -> datetime: ...
@epoch.setter
def epoch(self, value) -> None: ...
def epoch(self, value: datetime) -> None: ...
@property
def read_only(self): ...
def read_only(self) -> bool: ...
@property
def data_only(self): ...
def data_only(self) -> bool: ...
@property
def write_only(self): ...
def write_only(self) -> bool: ...
@property
def excel_base_date(self): ...
def excel_base_date(self) -> datetime: ...
@property
def active(self): ...
def active(self) -> _WorkbookChild | None: ...
@active.setter
def active(self, value) -> None: ...
def create_sheet(self, title: Incomplete | None = ..., index: Incomplete | None = ...): ...
def move_sheet(self, sheet, offset: int = ...) -> None: ...
def remove(self, worksheet) -> None: ...
def remove_sheet(self, worksheet) -> None: ...
def create_chartsheet(self, title: Incomplete | None = ..., index: Incomplete | None = ...): ...
def get_sheet_by_name(self, name): ...
def __contains__(self, key): ...
def index(self, worksheet): ...
def get_index(self, worksheet): ...
def __getitem__(self, key): ...
def __delitem__(self, key) -> None: ...
def __iter__(self): ...
def get_sheet_names(self): ...
def active(self, value: _WorkbookChild | int) -> None: ...
def create_sheet(self, title: str | None = ..., index: int | None = ...): ...
def move_sheet(self, sheet: Worksheet | str, offset: int = ...) -> None: ...
def remove(self, worksheet: Worksheet) -> None: ...
def remove_sheet(self, worksheet: Worksheet) -> None: ...
def create_chartsheet(self, title: str | None = ..., index: int | None = ...) -> Chartsheet: ...
def get_sheet_by_name(self, name: str) -> Worksheet: ...
def __contains__(self, key: str) -> bool: ...
def index(self, worksheet: Worksheet) -> int: ...
def get_index(self, worksheet: Worksheet) -> int: ...
def __getitem__(self, key: str) -> Worksheet: ...
def __delitem__(self, key: str) -> None: ...
def __iter__(self) -> Iterator[Worksheet]: ...
def get_sheet_names(self) -> list[Worksheet]: ...
@property
def worksheets(self): ...
def worksheets(self) -> list[Worksheet]: ...
@property
def chartsheets(self): ...
def chartsheets(self) -> list[Chartsheet]: ...
@property
def sheetnames(self): ...
def sheetnames(self) -> list[str]: ...
def create_named_range(
self, name, worksheet: Incomplete | None = ..., value: Incomplete | None = ..., scope: Incomplete | None = ...
self, name: str, worksheet: Worksheet | None = ..., value: str | Incomplete | None = ..., scope: Incomplete | None = ...
) -> None: ...
def add_named_style(self, style) -> None: ...
def add_named_style(self, style: NamedStyle) -> None: ...
@property
def named_styles(self): ...
def get_named_ranges(self): ...
def add_named_range(self, named_range) -> None: ...
def get_named_range(self, name): ...
def remove_named_range(self, named_range) -> None: ...
def named_styles(self) -> list[str]: ...
def get_named_ranges(self) -> list[DefinedName] | tuple[DefinedName, ...]: ...
def add_named_range(self, named_range: DefinedName) -> None: ...
def get_named_range(self, name: str) -> DefinedName: ...
def remove_named_range(self, named_range: DefinedName) -> None: ...
@property
def mime_type(self): ...
def save(self, filename) -> None: ...
def mime_type(self) -> str: ...
def save(self, filename: StrPath | IO[bytes]) -> None: ...
@property
def style_names(self): ...
def copy_worksheet(self, from_worksheet): ...
def style_names(self) -> list[str]: ...
def copy_worksheet(self, from_worksheet: Worksheet) -> Worksheet | WriteOnlyWorksheet: ...
def close(self) -> None: ...

View File

@@ -1,7 +1,17 @@
from _typeshed import Incomplete
from collections.abc import Generator
from collections.abc import Generator, Iterable, Iterator
from datetime import datetime
from typing import overload
from typing_extensions import Literal
from openpyxl.cell.cell import Cell
from openpyxl.workbook.child import _WorkbookChild
from openpyxl.workbook.workbook import Workbook
from openpyxl.worksheet.cell_range import CellRange
from openpyxl.worksheet.datavalidation import DataValidation
from openpyxl.worksheet.pagebreak import ColBreak, RowBreak
from openpyxl.worksheet.table import Table, TableList
from openpyxl.worksheet.views import SheetView
class Worksheet(_WorkbookChild):
mime_type: str
@@ -24,106 +34,166 @@ class Worksheet(_WorkbookChild):
PAPERSIZE_A5: str
ORIENTATION_PORTRAIT: str
ORIENTATION_LANDSCAPE: str
def __init__(self, parent, title: Incomplete | None = ...) -> None: ...
def __init__(self, parent: Workbook, title: str | None = ...) -> None: ...
@property
def sheet_view(self): ...
def sheet_view(self) -> SheetView: ...
@property
def selected_cell(self): ...
def selected_cell(self) -> Cell: ...
@property
def active_cell(self): ...
def active_cell(self) -> Cell: ...
@property
def page_breaks(self): ...
def page_breaks(self) -> tuple[RowBreak, ColBreak]: ...
@property
def show_gridlines(self): ...
def show_gridlines(self) -> bool: ...
@property
def show_summary_below(self): ...
def show_summary_below(self) -> bool: ...
@property
def show_summary_right(self): ...
def show_summary_right(self) -> bool: ...
@property
def freeze_panes(self): ...
def freeze_panes(self) -> str | None: ...
@freeze_panes.setter
def freeze_panes(self, topLeftCell: Incomplete | None = ...) -> None: ...
def cell(self, row, column, value: Incomplete | None = ...): ...
def __getitem__(self, key): ...
def __setitem__(self, key, value) -> None: ...
def __iter__(self): ...
def __delitem__(self, key) -> None: ...
def cell(self, row: int, column: int, value: str | None = ...) -> Cell: ...
def __getitem__(self, key: str | int | slice) -> Cell | tuple[Cell, ...]: ...
def __setitem__(self, key: str, value: str) -> None: ...
def __iter__(self) -> Iterator[Cell]: ...
def __delitem__(self, key: str) -> None: ...
@property
def min_row(self): ...
def min_row(self) -> int: ...
@property
def max_row(self): ...
def max_row(self) -> int: ...
@property
def min_column(self): ...
def min_column(self) -> int: ...
@property
def max_column(self): ...
def calculate_dimension(self): ...
def max_column(self) -> int: ...
def calculate_dimension(self) -> str: ...
@property
def dimensions(self): ...
def dimensions(self) -> str: ...
@overload
def iter_rows(
self, min_row: int | None, max_row: int | None, min_col: int | None, max_col: int | None, values_only: Literal[True]
) -> Generator[tuple[str | float | datetime | None, ...], None, None]: ...
@overload
def iter_rows(
self,
min_row: Incomplete | None = ...,
max_row: Incomplete | None = ...,
min_col: Incomplete | None = ...,
max_col: Incomplete | None = ...,
values_only: bool = ...,
): ...
min_row: int | None = None,
max_row: int | None = None,
min_col: int | None = None,
max_col: int | None = None,
*,
values_only: Literal[True],
) -> Generator[tuple[str | float | datetime | None, ...], None, None]: ...
@overload
def iter_rows(
self,
min_row: int | None = ...,
max_row: int | None = ...,
min_col: int | None = ...,
max_col: int | None = ...,
values_only: Literal[False] = False,
) -> Generator[tuple[Cell, ...], None, None]: ...
@overload
def iter_rows(
self, min_row: int | None, max_row: int | None, min_col: int | None, max_col: int | None, values_only: bool
) -> Generator[tuple[Cell | str | float | datetime | None, ...], None, None]: ...
@overload
def iter_rows(
self,
min_row: int | None = None,
max_row: int | None = None,
min_col: int | None = None,
max_col: int | None = None,
*,
values_only: bool,
) -> Generator[tuple[Cell | str | float | datetime | None, ...], None, None]: ...
@property
def rows(self): ...
def rows(self) -> Generator[Cell, None, None]: ...
@property
def values(self) -> Generator[Incomplete, None, None]: ...
def values(self) -> Generator[str | float | datetime | None, None, None]: ...
@overload
def iter_cols(
self, min_col: int | None, max_col: int | None, min_row: int | None, max_row: int | None, values_only: Literal[True]
) -> Generator[tuple[str | float | datetime | None, ...], None, None]: ...
@overload
def iter_cols(
self,
min_col: Incomplete | None = ...,
max_col: Incomplete | None = ...,
min_row: Incomplete | None = ...,
max_row: Incomplete | None = ...,
values_only: bool = ...,
): ...
min_col: int | None = None,
max_col: int | None = None,
min_row: int | None = None,
max_row: int | None = None,
*,
values_only: Literal[True],
) -> Generator[tuple[str | float | datetime | None, ...], None, None]: ...
@overload
def iter_cols(
self,
min_col: int | None = ...,
max_col: int | None = ...,
min_row: int | None = ...,
max_row: int | None = ...,
values_only: Literal[False] = False,
) -> Generator[tuple[Cell, ...], None, None]: ...
@overload
def iter_cols(
self, min_col: int | None, max_col: int | None, min_row: int | None, max_row: int | None, values_only: bool
) -> Generator[tuple[Cell | str | float | datetime | None, ...], None, None]: ...
@overload
def iter_cols(
self,
min_col: int | None = None,
max_col: int | None = None,
min_row: int | None = None,
max_row: int | None = None,
*,
values_only: bool,
) -> Generator[tuple[Cell | str | float | datetime | None, ...], None, None]: ...
@property
def columns(self): ...
def set_printer_settings(self, paper_size, orientation) -> None: ...
def add_data_validation(self, data_validation) -> None: ...
def columns(self) -> Generator[Cell, None, None]: ...
def set_printer_settings(
self, paper_size: int | None, orientation: None | Literal["default", "portrait", "landscape"]
) -> None: ...
def add_data_validation(self, data_validation: DataValidation) -> None: ...
def add_chart(self, chart, anchor: Incomplete | None = ...) -> None: ...
def add_image(self, img, anchor: Incomplete | None = ...) -> None: ...
def add_table(self, table) -> None: ...
def add_table(self, table: Table) -> None: ...
@property
def tables(self): ...
def tables(self) -> TableList: ...
def add_pivot(self, pivot) -> None: ...
def merge_cells(
self,
range_string: Incomplete | None = ...,
start_row: Incomplete | None = ...,
start_column: Incomplete | None = ...,
end_row: Incomplete | None = ...,
end_column: Incomplete | None = ...,
range_string: str | None = ...,
start_row: int | None = ...,
start_column: int | None = ...,
end_row: int | None = ...,
end_column: int | None = ...,
) -> None: ...
@property
def merged_cell_ranges(self): ...
def merged_cell_ranges(self) -> list[CellRange]: ...
def unmerge_cells(
self,
range_string: Incomplete | None = ...,
start_row: Incomplete | None = ...,
start_column: Incomplete | None = ...,
end_row: Incomplete | None = ...,
end_column: Incomplete | None = ...,
range_string: str | None = ...,
start_row: int | None = ...,
start_column: int | None = ...,
end_row: int | None = ...,
end_column: int | None = ...,
) -> None: ...
def append(self, iterable) -> None: ...
def insert_rows(self, idx, amount: int = ...) -> None: ...
def insert_cols(self, idx, amount: int = ...) -> None: ...
def delete_rows(self, idx, amount: int = ...) -> None: ...
def delete_cols(self, idx, amount: int = ...) -> None: ...
def move_range(self, cell_range, rows: int = ..., cols: int = ..., translate: bool = ...) -> None: ...
def append(self, iterable: Iterable[Incomplete]) -> None: ...
def insert_rows(self, idx: int, amount: int = ...) -> None: ...
def insert_cols(self, idx: int, amount: int = ...) -> None: ...
def delete_rows(self, idx: int, amount: int = ...) -> None: ...
def delete_cols(self, idx: int, amount: int = ...) -> None: ...
def move_range(self, cell_range: CellRange | str, rows: int = ..., cols: int = ..., translate: bool = ...) -> None: ...
@property
def print_title_rows(self): ...
def print_title_rows(self) -> str | None: ...
@print_title_rows.setter
def print_title_rows(self, rows) -> None: ...
def print_title_rows(self, rows: str | None) -> None: ...
@property
def print_title_cols(self): ...
def print_title_cols(self) -> str | None: ...
@print_title_cols.setter
def print_title_cols(self, cols) -> None: ...
def print_title_cols(self, cols: str | None) -> None: ...
@property
def print_titles(self): ...
def print_titles(self) -> str | None: ...
@property
def print_area(self): ...
def print_area(self) -> list[str]: ...
@print_area.setter
def print_area(self, value) -> None: ...
def print_area(self, value: str | Iterable[str]) -> None: ...