Skip to content

Commit 13ccbe4

Browse files
committed
fix: use strict int type check to satisfy static type checker
Pyright correctly flags that `isinstance(to, bool)` doesn't narrow the `str | int` union since `bool` is a subclass of `int`. Use `type(to) is int` for a strict exact-type check that both satisfies the type checker and correctly excludes booleans.
1 parent ebd79bd commit 13ccbe4

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/reactpy_router/components.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def _navigate(to: str | int, replace: bool = False) -> VdomDict | None:
110110
def on_navigate_callback(_event: dict[str, Any]) -> None:
111111
set_location(Location(**_event))
112112

113-
if isinstance(to, int) and not isinstance(to, bool):
113+
if type(to) is int:
114114
# Integer navigation (go back/forward) — always delegate to JS;
115115
# the resulting popstate event is handled by the History component.
116116
return Navigate({"onNavigateCallback": on_navigate_callback, "to": to, "replace": replace})

0 commit comments

Comments
 (0)