From 491b5e84cd5119a87f58cb5c88755486dd4e58f8 Mon Sep 17 00:00:00 2001 From: Jonathan Slenders Date: Wed, 15 May 2024 10:42:32 +0000 Subject: [PATCH] Typing fix in FileHistory. --- src/prompt_toolkit/history.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/prompt_toolkit/history.py b/src/prompt_toolkit/history.py index c82358de2..2d497a020 100644 --- a/src/prompt_toolkit/history.py +++ b/src/prompt_toolkit/history.py @@ -15,7 +15,7 @@ import threading from abc import ABCMeta, abstractmethod from asyncio import get_running_loop -from typing import AsyncGenerator, Iterable, Sequence +from typing import AsyncGenerator, Iterable, Sequence, Union __all__ = [ "History", @@ -255,12 +255,15 @@ def append_string(self, string: str) -> None: pass +_StrOrBytesPath = Union[str, bytes, "os.PathLike[str]", "os.PathLike[bytes]"] + + class FileHistory(History): """ :class:`.History` class that stores all strings in a file. """ - def __init__(self, filename: str | os.PathLike) -> None: + def __init__(self, filename: _StrOrBytesPath) -> None: self.filename = filename super().__init__()