-
-
Couldn't load subscription status.
- Fork 1k
Make mypy happy #1831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make mypy happy #1831
Changes from all commits
7aa201e
e93b7e2
b709219
aad3660
148ce03
a410afa
9f084b5
eeeac1a
cb091a3
2f9421d
ef8f46b
4795910
4f6e5c8
d7f27c0
4d60907
83356ed
e297c8c
0c52f70
0ae4633
c84a3c4
4cea32d
b5fe26c
53d49f4
870e71b
54f9226
8ae1665
a1a059b
83a94b2
9d9c8cc
5ca0763
d3bad30
6fbf283
79c2749
232b70c
0f48929
759b04a
f366783
8b91a82
12a88fa
e7c0367
208ddd1
9277ed5
21a0985
8013641
02b19c6
f22f257
64db52e
6ee6189
7844c37
95e007b
beb1906
99491d1
b4418c5
da8db5e
4c605f4
96403b2
2f808c3
bb7f58a
84bc80e
26a8bb0
b99283e
336f000
a4072c4
aadfd0d
8675639
dccf167
fa5d6cf
865ef14
cb612c0
db3372d
844d9c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
| from __future__ import annotations | ||
|
|
||
| from operator import itemgetter | ||
| from typing import TYPE_CHECKING, Iterable, NamedTuple, cast | ||
| from typing import TYPE_CHECKING, Callable, Iterable, NamedTuple, cast | ||
|
|
||
| import rich.repr | ||
| from rich.console import Console, ConsoleOptions, RenderableType, RenderResult | ||
|
|
@@ -45,12 +45,23 @@ class ReflowResult(NamedTuple): | |
| class MapGeometry(NamedTuple): | ||
| """Defines the absolute location of a Widget.""" | ||
|
|
||
| region: Region # The (screen) region occupied by the widget | ||
| order: tuple[tuple[int, ...], ...] # A tuple of ints defining the painting order | ||
| clip: Region # A region to clip the widget by (if a Widget is within a container) | ||
| virtual_size: Size # The virtual size (scrollable region) of a widget if it is a container | ||
| container_size: Size # The container size (area not occupied by scrollbars) | ||
| virtual_region: Region # The region relative to the container (but not necessarily visible) | ||
| region: Region | ||
| """The (screen) region occupied by the widget.""" | ||
| order: tuple[tuple[int, int, int], ...] | ||
| """Tuple of tuples defining the painting order of the widget. | ||
|
|
||
| Each successive triple represents painting order information with regards to | ||
| ancestors in the DOM hierarchy and the last triple provides painting order | ||
| information for this specific widget. | ||
| """ | ||
| clip: Region | ||
| """A region to clip the widget by (if a Widget is within a container).""" | ||
| virtual_size: Size | ||
| """The virtual size (scrollable region) of a widget if it is a container.""" | ||
| container_size: Size | ||
| """The container size (area not occupied by scrollbars).""" | ||
| virtual_region: Region | ||
| """The region relative to the container (but not necessarily visible).""" | ||
|
|
||
| @property | ||
| def visible_region(self) -> Region: | ||
|
|
@@ -419,19 +430,23 @@ def add_widget( | |
| widget: Widget, | ||
| virtual_region: Region, | ||
| region: Region, | ||
| order: tuple[tuple[int, ...], ...], | ||
| order: tuple[tuple[int, int, int], ...], | ||
| layer_order: int, | ||
| clip: Region, | ||
| visible: bool, | ||
| _MapGeometry=MapGeometry, | ||
| _MapGeometry: type[MapGeometry] = MapGeometry, | ||
| ) -> None: | ||
| """Called recursively to place a widget and its children in the map. | ||
|
|
||
| Args: | ||
| widget: The widget to add. | ||
| virtual_region: The Widget region relative to it's container. | ||
| region: The region the widget will occupy. | ||
| order: A tuple of ints to define the order. | ||
| order: Painting order information. | ||
| layer_order: The order of the widget in its layer. | ||
| clip: The clipping region (i.e. the viewport which contains it). | ||
| visible: Whether the widget should be visible by default. | ||
| This may be overriden by the CSS rule `visibility`. | ||
| """ | ||
| visibility = widget.styles.get_rule("visibility") | ||
| if visibility is not None: | ||
|
|
@@ -501,11 +516,12 @@ def add_widget( | |
| ) | ||
| widget_region = sub_region + placement_scroll_offset | ||
|
|
||
| widget_order = ( | ||
| *order, | ||
| get_layer_index(sub_widget.layer, 0), | ||
| z, | ||
| layer_order, | ||
| widget_order = order + ( | ||
| ( | ||
| get_layer_index(sub_widget.layer, 0), | ||
| z, | ||
| layer_order, | ||
| ), | ||
| ) | ||
|
|
||
| add_widget( | ||
|
|
@@ -560,7 +576,7 @@ def add_widget( | |
| root, | ||
| size.region, | ||
| size.region, | ||
| ((0,),), | ||
| ((0, 0, 0),), | ||
| layer_order, | ||
| size.region, | ||
| True, | ||
|
|
@@ -818,11 +834,8 @@ def render(self, full: bool = False) -> RenderableType | None: | |
| # Maps each cut on to a list of segments | ||
| cuts = self.cuts | ||
|
|
||
| # dict.fromkeys is a callable which takes a list of ints returns a dict which maps ints on to a list of Segments or None. | ||
| fromkeys = cast( | ||
| "Callable[[list[int]], dict[int, list[Segment] | None]]", dict.fromkeys | ||
| ) | ||
| # A mapping of cut index to a list of segments for each line | ||
| # dict.fromkeys is a callable which takes a list of ints returns a dict which maps ints onto a Segment or None. | ||
| fromkeys = cast("Callable[[list[int]], dict[int, Strip | None]]", dict.fromkeys) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment above needs updating. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The diff isn't great, but the comment is correct: it's "# dict.fromkeys is a callable [...]" and is the old line 821 / the new line 837... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment references |
||
| chops: list[dict[int, Strip | None]] | ||
| chops = [fromkeys(cut_set[:-1]) for cut_set in cuts] | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.