Merge pull request #1765 from Textualize/typing-10-feb

typing fixes
This commit is contained in:
Will McGugan
2023-02-10 10:06:24 +00:00
committed by GitHub
5 changed files with 5 additions and 5 deletions

View File

@@ -183,7 +183,7 @@ def parse_declarations(css: str, path: str) -> Styles:
styles_builder = StylesBuilder() styles_builder = StylesBuilder()
declaration: Declaration | None = None declaration: Declaration | None = None
errors: list[tuple[Token, str]] = [] errors: list[tuple[Token, str | HelpText]] = []
while True: while True:
token = next(tokens, None) token = next(tokens, None)

View File

@@ -255,7 +255,7 @@ class DOMQuery(Generic[QueryType]):
# The IndexError was got, that's a good thing in this case. So # The IndexError was got, that's a good thing in this case. So
# we return what we found. # we return what we found.
pass pass
return the_one return cast("Widget", the_one)
@overload @overload
def last(self) -> Widget: def last(self) -> Widget:

View File

@@ -474,7 +474,7 @@ class StylesBase(ABC):
@classmethod @classmethod
@lru_cache(maxsize=1024) @lru_cache(maxsize=1024)
def parse(cls, css: str, path: str, *, node: DOMNode = None) -> Styles: def parse(cls, css: str, path: str, *, node: DOMNode | None = None) -> Styles:
"""Parse CSS and return a Styles object. """Parse CSS and return a Styles object.
Args: Args:

View File

@@ -111,7 +111,7 @@ class DOMNode(MessagePump):
_css_type_names: ClassVar[frozenset[str]] = frozenset() _css_type_names: ClassVar[frozenset[str]] = frozenset()
# Generated list of bindings # Generated list of bindings
_merged_bindings: ClassVar[Bindings] | None = None _merged_bindings: ClassVar[Bindings | None] = None
_reactives: ClassVar[dict[str, Reactive]] _reactives: ClassVar[dict[str, Reactive]]

View File

@@ -231,7 +231,7 @@ class Screen(Widget):
else: else:
# Only move the focus if we are currently showing the focus # Only move the focus if we are currently showing the focus
if direction: if direction:
to_focus: Widget | None = None to_focus = None
chain_length = len(focus_chain) chain_length = len(focus_chain)
for step in range(1, len(focus_chain) + 1): for step in range(1, len(focus_chain) + 1):
node = focus_chain[ node = focus_chain[