mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Test fix, query typing
This commit is contained in:
@@ -16,7 +16,7 @@ a method which evaluates the query, such as first() and last().
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Generic, TYPE_CHECKING, Iterator, TypeVar, overload
|
||||
from typing import cast, Generic, TYPE_CHECKING, Iterator, TypeVar, overload
|
||||
|
||||
import rich.repr
|
||||
|
||||
@@ -64,7 +64,7 @@ class DOMQuery(Generic[QueryType]):
|
||||
) -> None:
|
||||
|
||||
self._node = node
|
||||
self._nodes: list[Widget] | None = None
|
||||
self._nodes: list[QueryType] | None = None
|
||||
self._filters: list[tuple[SelectorSet, ...]] = (
|
||||
parent._filters.copy() if parent else []
|
||||
)
|
||||
@@ -96,7 +96,7 @@ class DOMQuery(Generic[QueryType]):
|
||||
for node in nodes
|
||||
if not any(match(selector_set, node) for selector_set in self._excludes)
|
||||
]
|
||||
self._nodes = nodes
|
||||
self._nodes = cast("list[QueryType]", nodes)
|
||||
return self._nodes
|
||||
|
||||
def __len__(self) -> int:
|
||||
|
||||
@@ -690,7 +690,7 @@ class DOMNode(MessagePump):
|
||||
"""Get a DOM query matching a selector.
|
||||
|
||||
Args:
|
||||
selector (str, optional): A CSS selector or `None` for all nodes. Defaults to None.
|
||||
selector (str | type | None, optional): A CSS selector or `None` for all nodes. Defaults to None.
|
||||
|
||||
Returns:
|
||||
DOMQuery: A query object.
|
||||
@@ -725,7 +725,7 @@ class DOMNode(MessagePump):
|
||||
"""Get the first Widget matching the given selector or selector type.
|
||||
|
||||
Args:
|
||||
selector (str | None, optional): A selector.
|
||||
selector (str | type, optional): A selector.
|
||||
expect_type (type, optional): Require the object be of the supplied type, or None for any type.
|
||||
Defaults to None.
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user