11from __future__ import annotations
22
3- import sys
43import typing
5- from typing import TYPE_CHECKING , Callable , Literal
6-
7- if sys .version_info < (3 , 10 ):
8- from typing_extensions import TypeAlias
9- else :
10- from typing import TypeAlias
4+ from collections .abc import Callable
5+ from typing import TYPE_CHECKING , Literal , TypeAlias
116
127if TYPE_CHECKING :
138 import pandas as pd
@@ -101,7 +96,7 @@ def visible(self) -> SheetVisible:
10196 """The visibility of the sheet"""
10297 return self ._sheet .visible
10398
104- def to_arrow (self ) -> " pa.RecordBatch" :
99+ def to_arrow (self ) -> pa .RecordBatch :
105100 """Converts the sheet to a pyarrow `RecordBatch`
106101
107102 Requires the `pyarrow` extra to be installed.
@@ -112,7 +107,7 @@ def to_arrow(self) -> "pa.RecordBatch":
112107 )
113108 return self ._sheet .to_arrow ()
114109
115- def to_arrow_with_errors (self ) -> " tuple[pa.RecordBatch, CellErrors | None]" :
110+ def to_arrow_with_errors (self ) -> tuple [pa .RecordBatch , CellErrors | None ]:
116111 """Converts the sheet to a pyarrow `RecordBatch` with error information.
117112
118113 Stores the positions of any values that cannot be parsed as the specified type and were
@@ -129,7 +124,7 @@ def to_arrow_with_errors(self) -> "tuple[pa.RecordBatch, CellErrors | None]":
129124 return (rb , None )
130125 return (rb , cell_errors )
131126
132- def to_pandas (self ) -> " pd.DataFrame" :
127+ def to_pandas (self ) -> pd .DataFrame :
133128 """Converts the sheet to a Pandas `DataFrame`.
134129
135130 Requires the `pandas` extra to be installed.
@@ -139,7 +134,7 @@ def to_pandas(self) -> "pd.DataFrame":
139134 # (see https://pandas.pydata.org/docs/reference/api/pandas.api.interchange.from_dataframe.html)
140135 return self .to_arrow ().to_pandas ()
141136
142- def to_polars (self ) -> " pl.DataFrame" :
137+ def to_polars (self ) -> pl .DataFrame :
143138 """Converts the sheet to a Polars `DataFrame`.
144139
145140 Uses the Arrow PyCapsule Interface for zero-copy data exchange.
@@ -225,7 +220,7 @@ def specified_dtypes(self) -> DTypeMap | None:
225220 """The dtypes specified for the table"""
226221 return self ._table .specified_dtypes
227222
228- def to_arrow (self ) -> " pa.RecordBatch" :
223+ def to_arrow (self ) -> pa .RecordBatch :
229224 """Converts the table to a pyarrow `RecordBatch`
230225
231226 Requires the `pyarrow` extra to be installed.
@@ -236,7 +231,7 @@ def to_arrow(self) -> "pa.RecordBatch":
236231 )
237232 return self ._table .to_arrow ()
238233
239- def to_pandas (self ) -> " pd.DataFrame" :
234+ def to_pandas (self ) -> pd .DataFrame :
240235 """Converts the table to a Pandas `DataFrame`.
241236
242237 Requires the `pandas` extra to be installed.
@@ -246,7 +241,7 @@ def to_pandas(self) -> "pd.DataFrame":
246241 # (see https://pandas.pydata.org/docs/reference/api/pandas.api.interchange.from_dataframe.html)
247242 return self .to_arrow ().to_pandas ()
248243
249- def to_polars (self ) -> " pl.DataFrame" :
244+ def to_polars (self ) -> pl .DataFrame :
250245 """Converts the table to a Polars `DataFrame`.
251246
252247 Uses the Arrow PyCapsule Interface for zero-copy data exchange.
@@ -328,7 +323,7 @@ def load_sheet(
328323 | None = None ,
329324 dtypes : DType | DTypeMap | None = None ,
330325 eager : Literal [True ] = ...,
331- ) -> " pa.RecordBatch" : ...
326+ ) -> pa .RecordBatch : ...
332327
333328 def load_sheet (
334329 self ,
@@ -347,7 +342,7 @@ def load_sheet(
347342 | None = None ,
348343 dtypes : DType | DTypeMap | None = None ,
349344 eager : bool = False ,
350- ) -> " ExcelSheet | pa.RecordBatch" :
345+ ) -> ExcelSheet | pa .RecordBatch :
351346 """Loads a sheet by index or name.
352347
353348 :param idx_or_name: The index (starting at 0) or the name of the sheet to load.
@@ -469,7 +464,7 @@ def load_table(
469464 | None = None ,
470465 dtypes : DType | DTypeMap | None = None ,
471466 eager : Literal [True ] = ...,
472- ) -> " pa.RecordBatch" : ...
467+ ) -> pa .RecordBatch : ...
473468
474469 def load_table (
475470 self ,
@@ -488,7 +483,7 @@ def load_table(
488483 | None = None ,
489484 dtypes : DType | DTypeMap | None = None ,
490485 eager : bool = False ,
491- ) -> " ExcelTable | pa.RecordBatch" :
486+ ) -> ExcelTable | pa .RecordBatch :
492487 """Loads a table by name.
493488
494489 :param name: The name of the table to load.
@@ -574,7 +569,7 @@ def load_sheet_eager(
574569 dtype_coercion : Literal ["coerce" , "strict" ] = "coerce" ,
575570 use_columns : list [str ] | list [int ] | str | None = None ,
576571 dtypes : DType | DTypeMap | None = None ,
577- ) -> " pa.RecordBatch" :
572+ ) -> pa .RecordBatch :
578573 """Loads a sheet eagerly by index or name.
579574
580575 For xlsx files, this will be faster and more memory-efficient, as it will use
@@ -672,7 +667,7 @@ def read_excel(source: Path | str | bytes) -> ExcelReader:
672667
673668 :param source: The path to a file or its content as bytes
674669 """
675- if isinstance (source , ( str , Path ) ):
670+ if isinstance (source , str | Path ):
676671 source = expanduser (source )
677672 return ExcelReader (_read_excel (source ))
678673
0 commit comments