Skip to content

Commit cf03500

Browse files
committed
v0.6.0-post1 [Fix mypy no-any-return errors]
1 parent a754566 commit cf03500

1 file changed

Lines changed: 61 additions & 43 deletions

File tree

src/ctk_interactive_canvas/interactive_canvas.py

Lines changed: 61 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"""
1010

1111
from tkinter import Event, Canvas as TkCanvas
12-
from typing import Any, Callable, Dict, FrozenSet, List, Optional, Tuple
12+
from typing import Any, Callable, Dict, FrozenSet, List, Optional, Tuple, cast
1313

1414
import customtkinter as ctk
1515

@@ -506,17 +506,20 @@ def create_draggable_rectangle(
506506
Returns:
507507
The created DraggableRectangle instance
508508
"""
509-
return self._dispatch(
510-
"create_draggable_rectangle",
511-
self._builtin_create_draggable_rectangle,
512-
x1,
513-
y1,
514-
x2,
515-
y2,
516-
offset=offset,
517-
max_repetitions=max_repetitions,
518-
center_on_canvas=center_on_canvas,
519-
**kwargs,
509+
return cast(
510+
DraggableRectangle,
511+
self._dispatch(
512+
"create_draggable_rectangle",
513+
self._builtin_create_draggable_rectangle,
514+
x1,
515+
y1,
516+
x2,
517+
y2,
518+
offset=offset,
519+
max_repetitions=max_repetitions,
520+
center_on_canvas=center_on_canvas,
521+
**kwargs,
522+
),
520523
)
521524

522525
def _builtin_create_draggable_rectangle(
@@ -604,13 +607,16 @@ def copy_draggable_rectangle(
604607
Returns:
605608
The copied DraggableRectangle instance
606609
"""
607-
return self._dispatch(
608-
"copy_draggable_rectangle",
609-
self._builtin_copy_draggable_rectangle,
610-
draggable_rect,
611-
offset=offset,
612-
max_repetitions=max_repetitions,
613-
**kwargs,
610+
return cast(
611+
DraggableRectangle,
612+
self._dispatch(
613+
"copy_draggable_rectangle",
614+
self._builtin_copy_draggable_rectangle,
615+
draggable_rect,
616+
offset=offset,
617+
max_repetitions=max_repetitions,
618+
**kwargs,
619+
),
614620
)
615621

616622
def _builtin_copy_draggable_rectangle(
@@ -1553,35 +1559,47 @@ def _recreate_attached_item(self, snapshot: Dict[str, Any]) -> Optional[int]:
15531559
tags = tuple(snapshot.get("tags", ()))
15541560

15551561
if item_type == "text":
1556-
return self.create_text(
1557-
*item_coords,
1558-
text=snapshot.get("text", ""),
1559-
font=snapshot.get("font", ""),
1560-
fill=snapshot.get("fill", "black"),
1561-
anchor=snapshot.get("anchor", "center"),
1562-
tags=tags,
1562+
return cast(
1563+
int,
1564+
self.create_text(
1565+
*item_coords,
1566+
text=snapshot.get("text", ""),
1567+
font=snapshot.get("font", ""),
1568+
fill=snapshot.get("fill", "black"),
1569+
anchor=snapshot.get("anchor", "center"),
1570+
tags=tags,
1571+
),
15631572
)
15641573
elif item_type == "rectangle":
1565-
return self.create_rectangle(
1566-
*item_coords,
1567-
fill=snapshot.get("fill", ""),
1568-
outline=snapshot.get("outline", "black"),
1569-
width=float(snapshot.get("width", 1)),
1570-
tags=tags,
1574+
return cast(
1575+
int,
1576+
self.create_rectangle(
1577+
*item_coords,
1578+
fill=snapshot.get("fill", ""),
1579+
outline=snapshot.get("outline", "black"),
1580+
width=float(snapshot.get("width", 1)),
1581+
tags=tags,
1582+
),
15711583
)
15721584
elif item_type == "line":
1573-
return self.create_line(
1574-
*item_coords,
1575-
fill=snapshot.get("fill", "black"),
1576-
width=float(snapshot.get("width", 1)),
1577-
tags=tags,
1585+
return cast(
1586+
int,
1587+
self.create_line(
1588+
*item_coords,
1589+
fill=snapshot.get("fill", "black"),
1590+
width=float(snapshot.get("width", 1)),
1591+
tags=tags,
1592+
),
15781593
)
15791594
elif item_type == "oval":
1580-
return self.create_oval(
1581-
*item_coords,
1582-
fill=snapshot.get("fill", ""),
1583-
outline=snapshot.get("outline", "black"),
1584-
width=float(snapshot.get("width", 1)),
1585-
tags=tags,
1595+
return cast(
1596+
int,
1597+
self.create_oval(
1598+
*item_coords,
1599+
fill=snapshot.get("fill", ""),
1600+
outline=snapshot.get("outline", "black"),
1601+
width=float(snapshot.get("width", 1)),
1602+
tags=tags,
1603+
),
15861604
)
15871605
return None

0 commit comments

Comments
 (0)