Skip to content

Commit 19a0846

Browse files
authored
Merge branch 'main' into markdown-number-list
2 parents b9726bb + 0750bc2 commit 19a0846

File tree

7 files changed

+40
-17
lines changed

7 files changed

+40
-17
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8-
## [0.18.0] - Unreleased
8+
## Unreleased
99

1010
### Fixed
1111

12+
- Fixed bindings persistance https://github.com/Textualize/textual/issues/1613
1213
- The `Markdown` widget now auto-increments ordered lists https://github.com/Textualize/textual/issues/2002
1314

1415
## [0.17.1] - 2023-03-30

docs/images/stopwatch_widgets.excalidraw.svg

Lines changed: 6 additions & 6 deletions
Loading

docs/tutorial.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ This will be a simple yet **fully featured** app — you could distribute th
2525
Here's what the finished app will look like:
2626

2727

28-
```{.textual path="docs/examples/tutorial/stopwatch.py" press="tab,enter,tab,enter,tab,enter,tab,enter"}
28+
```{.textual path="docs/examples/tutorial/stopwatch.py" title="stopwatch.py" press="tab,enter,tab,enter,tab,enter,tab,enter"}
2929
```
3030

3131
### Get the code
@@ -90,12 +90,12 @@ The first step in building a Textual app is to import and extend the `App` class
9090
If you run this code, you should see something like the following:
9191

9292

93-
```{.textual path="docs/examples/tutorial/stopwatch01.py"}
93+
```{.textual path="docs/examples/tutorial/stopwatch01.py" title="stopwatch01.py"}
9494
```
9595

9696
Hit the ++d++ key to toggle between light and dark mode.
9797

98-
```{.textual path="docs/examples/tutorial/stopwatch01.py" press="d" title="StopwatchApp + dark"}
98+
```{.textual path="docs/examples/tutorial/stopwatch01.py" press="d" title="stopwatch01.py"}
9999
```
100100

101101
Hit ++ctrl+c++ to exit the app and return to the command prompt.
@@ -449,7 +449,7 @@ The `action_remove_stopwatch` function calls [query()][textual.dom.DOMNode.query
449449

450450
If you run `stopwatch.py` now you can add a new stopwatch with the ++a++ key and remove a stopwatch with ++r++.
451451

452-
```{.textual path="docs/examples/tutorial/stopwatch.py" press="d,a,a,a,a,a,a,a,tab,enter,tab"}
452+
```{.textual path="docs/examples/tutorial/stopwatch.py" title="stopwatch.py" press="d,a,a,a,a,a,a,a,tab,enter,tab"}
453453
```
454454

455455
## What next?

src/textual/_import_app.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,11 @@ def import_app(import_name: str) -> App:
112112
except ImportError as error:
113113
raise AppFail(str(error))
114114

115+
find_app = name or "app"
115116
try:
116-
app = getattr(module, name or "app")
117+
app = getattr(module, find_app or "app")
117118
except AttributeError:
118-
raise AppFail(f"Unable to find {name!r} in {module!r}")
119+
raise AppFail(f"Unable to find {find_app!r} in {module!r}")
119120

120121
sys.argv[:] = [import_name, *argv]
121122

src/textual/_types.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,11 @@ def post_message(self, message: "Message") -> bool:
2525

2626
SegmentLines = List[List["Segment"]]
2727
CallbackType = Union[Callable[[], Awaitable[None]], Callable[[], None]]
28-
WatchCallbackType = Union[Callable[[Any], Awaitable[None]], Callable[[Any], None]]
28+
WatchCallbackType = Union[
29+
Callable[[], Awaitable[None]],
30+
Callable[[Any], Awaitable[None]],
31+
Callable[[Any, Any], Awaitable[None]],
32+
Callable[[], None],
33+
Callable[[Any], None],
34+
Callable[[Any, Any], None],
35+
]

src/textual/binding.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from dataclasses import dataclass
4-
from typing import TYPE_CHECKING, Iterable, MutableMapping
4+
from typing import TYPE_CHECKING, Iterable
55

66
import rich.repr
77

@@ -92,12 +92,22 @@ def make_bindings(bindings: Iterable[BindingType]) -> Iterable[Binding]:
9292
priority=binding.priority,
9393
)
9494

95-
self.keys: MutableMapping[str, Binding] = (
95+
self.keys: dict[str, Binding] = (
9696
{binding.key: binding for binding in make_bindings(bindings)}
9797
if bindings
9898
else {}
9999
)
100100

101+
def copy(self) -> Bindings:
102+
"""Return a copy of this instance.
103+
104+
Return:
105+
New bindings object.
106+
"""
107+
copy = Bindings()
108+
copy.keys = self.keys.copy()
109+
return copy
110+
101111
def __rich_repr__(self) -> rich.repr.Result:
102112
yield self.keys
103113

src/textual/dom.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,11 @@ def __init__(
165165
self._auto_refresh: float | None = None
166166
self._auto_refresh_timer: Timer | None = None
167167
self._css_types = {cls.__name__ for cls in self._css_bases(self.__class__)}
168-
self._bindings = self._merged_bindings or Bindings()
168+
self._bindings = (
169+
Bindings()
170+
if self._merged_bindings is None
171+
else self._merged_bindings.copy()
172+
)
169173
self._has_hover_style: bool = False
170174
self._has_focus_within: bool = False
171175

0 commit comments

Comments
 (0)