11from __future__ import annotations
22
3+ import os
34from dataclasses import dataclass
45from pathlib import Path
56from typing import ClassVar
67
78from rich .style import Style
89from rich .text import Text , TextType
910
10- from .._types import MessageTarget
1111from ..message import Message
1212from ._tree import TOGGLE_STYLE , Tree , TreeNode
1313
1414
1515@dataclass
1616class DirEntry :
17- """Attaches directory information ot a node."""
17+ """Attaches directory information to a node."""
1818
1919 path : str
2020 is_dir : bool
@@ -26,9 +26,9 @@ class DirectoryTree(Tree[DirEntry]):
2626
2727 Args:
2828 path: Path to directory.
29- name: The name of the widget, or None for no name. Defaults to None.
30- id: The ID of the widget in the DOM, or None for no ID. Defaults to None.
31- classes: A space-separated list of classes, or None for no classes. Defaults to None.
29+ name: The name of the widget, or None for no name.
30+ id: The ID of the widget in the DOM, or None for no ID.
31+ classes: A space-separated list of classes, or None for no classes.
3232 disabled: Whether the directory tree is disabled or not.
3333 """
3434
@@ -83,17 +83,18 @@ def __init__(self, path: str) -> None:
8383
8484 def __init__ (
8585 self ,
86- path : str ,
86+ path : str | Path ,
8787 * ,
8888 name : str | None = None ,
8989 id : str | None = None ,
9090 classes : str | None = None ,
9191 disabled : bool = False ,
9292 ) -> None :
93- self .path = path
93+ str_path = os .fspath (path )
94+ self .path = str_path
9495 super ().__init__ (
95- path ,
96- data = DirEntry (path , True ),
96+ str_path ,
97+ data = DirEntry (str_path , True ),
9798 name = name ,
9899 id = id ,
99100 classes = classes ,
0 commit comments