Skip to content

Commit ad517c7

Browse files
bashtageKevin Sheppard
and
Kevin Sheppard
authored
ENH: Improve Styler typing (#282)
* ENH: Improve styler typing * TYP: Add typing for StylerRenderer * ENH: Improve Styler * ENH: Improve definition os subset * BUG: Overcome 3.8 limit * BUG: Fix IndexSlice type * MAINT: Set backend for MPL * TYP: Simplify types * TYP: Improve axis * TYP: Remove attributes * TYP: Final small fixes * TYP: Small fixes for Styler pipe Co-authored-by: Kevin Sheppard <kevin.sheppard@gmail.com>
1 parent bed018c commit ad517c7

File tree

9 files changed

+651
-87
lines changed

9 files changed

+651
-87
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: 'Test'
22

33
on:
44
[push, pull_request, workflow_dispatch]
5+
6+
env:
7+
MPLBACKEND: 'Agg'
8+
59
jobs:
610
released:
711
runs-on: ${{ matrix.os }}

pandas-stubs/_typing.pyi

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ from typing import (
2020
Optional,
2121
Protocol,
2222
Sequence,
23+
TypedDict,
2324
TypeVar,
2425
Union,
2526
)
@@ -249,4 +250,14 @@ FileWriteMode = Literal[
249250
]
250251
ColspaceArgType = str | int | Sequence[int | str] | Mapping[Hashable, str | int]
251252

253+
class StyleExportDict(TypedDict, total=False):
254+
apply: Any
255+
table_attributes: Any
256+
table_styles: Any
257+
hide_index: bool
258+
hide_columns: bool
259+
hide_index_names: bool
260+
hide_column_names: bool
261+
css: dict[str, str | int]
262+
252263
__all__ = ["npt", "type_t"]

pandas-stubs/core/indexing.pyi

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
from typing import (
2+
Generic,
3+
TypeVar,
4+
Union,
5+
)
6+
17
import numpy as np
28
from pandas.core.indexes.api import Index
39

@@ -7,8 +13,10 @@ from pandas._typing import (
713
StrLike,
814
)
915

10-
class _IndexSlice:
11-
def __getitem__(self, arg) -> tuple[StrLike | Scalar | slice, ...]: ...
16+
_IndexSliceT = TypeVar("_IndexSliceT", bound=Union[StrLike, Scalar, slice])
17+
18+
class _IndexSlice(Generic[_IndexSliceT]):
19+
def __getitem__(self, arg) -> tuple[_IndexSliceT, ...]: ...
1220

1321
IndexSlice: _IndexSlice
1422

0 commit comments

Comments
 (0)