diff --git a/examples/markdown.py b/examples/markdown.py index e2f1fc020..140c89038 100644 --- a/examples/markdown.py +++ b/examples/markdown.py @@ -12,7 +12,7 @@ class MarkdownApp(App): ("f", "forward", "Forward"), ] - path = var(str(Path(__file__).parent / "demo.md")) + path = var(Path(__file__).parent / "demo.md") @property def markdown_viewer(self) -> MarkdownViewer: diff --git a/src/textual/widgets/_markdown.py b/src/textual/widgets/_markdown.py index 3fc6958fa..9db1cf0a1 100644 --- a/src/textual/widgets/_markdown.py +++ b/src/textual/widgets/_markdown.py @@ -1,6 +1,6 @@ from __future__ import annotations -from pathlib import Path +from pathlib import Path, PurePath from typing import Iterable from markdown_it import MarkdownIt @@ -37,7 +37,7 @@ class Navigator: return Path(".") return self.stack[self.index] - def go(self, path: str) -> Path: + def go(self, path: str | PurePath) -> Path: """Go to a new document. Args: @@ -749,7 +749,7 @@ class MarkdownViewer(Vertical, can_focus=True, can_focus_children=True): if self._markdown is not None: await self.document.update(self._markdown) - async def go(self, location: str) -> bool: + async def go(self, location: str | PurePath) -> bool: """Navigate to a new document path.""" return await self.document.load(self.navigator.go(location))