diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-05 04:45:15 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-05 04:45:15 +0000 |
commit | 6dc655898df34ad424dfc467a8b276fdf31bd791 (patch) | |
tree | 0a3f3addbfc0b81e3850a628afe62ce830a8b0f3 /src/prompt_toolkit/history.py | |
parent | Releasing progress-linux version 3.0.43-2~progress7.99u1. (diff) | |
download | prompt-toolkit-6dc655898df34ad424dfc467a8b276fdf31bd791.tar.xz prompt-toolkit-6dc655898df34ad424dfc467a8b276fdf31bd791.zip |
Merging upstream version 3.0.46.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/prompt_toolkit/history.py')
-rw-r--r-- | src/prompt_toolkit/history.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/prompt_toolkit/history.py b/src/prompt_toolkit/history.py index 553918e..2d497a0 100644 --- a/src/prompt_toolkit/history.py +++ b/src/prompt_toolkit/history.py @@ -7,6 +7,7 @@ NOTE: There is no `DynamicHistory`: loading can be done asynchronously and making the history swappable would probably break this. """ + from __future__ import annotations import datetime @@ -14,7 +15,7 @@ import os 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", @@ -254,12 +255,15 @@ class DummyHistory(History): 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) -> None: + def __init__(self, filename: _StrOrBytesPath) -> None: self.filename = filename super().__init__() @@ -297,6 +301,6 @@ class FileHistory(History): def write(t: str) -> None: f.write(t.encode("utf-8")) - write("\n# %s\n" % datetime.datetime.now()) + write(f"\n# {datetime.datetime.now()}\n") for line in string.split("\n"): - write("+%s\n" % line) + write(f"+{line}\n") |