Skip to content

Commit

Permalink
Tweak type hints for updated stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
jsvine committed Jul 6, 2024
1 parent caaf825 commit 915c168
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 6 additions & 7 deletions pdfplumber/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
from .table import T_table_settings, Table, TableFinder, TableSettings

if TYPE_CHECKING: # pragma: nocover
from pandas.core.frame import DataFrame
from pandas.core.series import Series
import pandas as pd

from .page import Page

Expand Down Expand Up @@ -199,7 +198,7 @@ def draw_line(

def draw_lines(
self,
list_of_lines: Union[T_seq[T_contains_points], "DataFrame"],
list_of_lines: Union[T_seq[T_contains_points], "pd.DataFrame"],
stroke: T_color = DEFAULT_STROKE,
stroke_width: int = DEFAULT_STROKE_WIDTH,
) -> "PageImage":
Expand All @@ -219,7 +218,7 @@ def draw_vline(

def draw_vlines(
self,
locations: Union[List[T_num], "Series"],
locations: Union[List[T_num], "pd.Series[float]"],
stroke: T_color = DEFAULT_STROKE,
stroke_width: int = DEFAULT_STROKE_WIDTH,
) -> "PageImage":
Expand All @@ -239,7 +238,7 @@ def draw_hline(

def draw_hlines(
self,
locations: Union[List[T_num], "Series"],
locations: Union[List[T_num], "pd.Series[float]"],
stroke: T_color = DEFAULT_STROKE,
stroke_width: int = DEFAULT_STROKE_WIDTH,
) -> "PageImage":
Expand Down Expand Up @@ -282,7 +281,7 @@ def draw_rect(

def draw_rects(
self,
list_of_rects: Union[List[T_bbox], T_obj_list, "DataFrame"],
list_of_rects: Union[List[T_bbox], T_obj_list, "pd.DataFrame"],
fill: T_color = DEFAULT_FILL,
stroke: T_color = DEFAULT_STROKE,
stroke_width: int = DEFAULT_STROKE_WIDTH,
Expand Down Expand Up @@ -310,7 +309,7 @@ def draw_circle(

def draw_circles(
self,
list_of_circles: Union[List[T_point], T_obj_list, "DataFrame"],
list_of_circles: Union[List[T_point], T_obj_list, "pd.DataFrame"],
radius: int = 5,
fill: T_color = DEFAULT_FILL,
stroke: T_color = DEFAULT_STROKE,
Expand Down
4 changes: 2 additions & 2 deletions pdfplumber/utils/generic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections.abc import Sequence
from typing import TYPE_CHECKING, Any, Dict, List, Union
from typing import TYPE_CHECKING, Any, Dict, Hashable, List, Union

from .._typing import T_seq

Expand All @@ -13,7 +13,7 @@ def to_list(collection: Union[T_seq[Any], "DataFrame"]) -> List[Any]:
elif isinstance(collection, Sequence):
return list(collection)
elif hasattr(collection, "to_dict"):
res: List[Dict[Union[str, int], Any]] = collection.to_dict(
res: List[Dict[Hashable, Any]] = collection.to_dict(
"records"
) # pragma: nocover
return res
Expand Down

0 comments on commit 915c168

Please sign in to comment.