Skip to content

Commit

Permalink
Check that token is not None.
Browse files Browse the repository at this point in the history
Checking if the token is not 'None' brings us a tiny step closer to fixing #1849, which still needs to ensure the variable definition is complete and valid, even if empty.
  • Loading branch information
rodrigogiraoserrao committed Feb 21, 2023
1 parent c84a3c4 commit 4cea32d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 1 addition & 3 deletions mypy.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
poetry run mypy src/textual
src/textual/_two_way_dict.py:41: error: Incompatible return value type (got "Optional[Value]", expected "Value") [return-value]
src/textual/_two_way_dict.py:52: error: Incompatible return value type (got "Optional[Key]", expected "Key") [return-value]
src/textual/css/parse.py:278: error: Item "None" of "Optional[Token]" has no attribute "name" [union-attr]
src/textual/css/parse.py:279: error: Incompatible types in "yield" (actual type "Optional[Token]", expected type "Token") [misc]
src/textual/dom.py:794: error: Incompatible return value type (got "DOMQuery[<nothing>]", expected "Union[DOMQuery[Widget], DOMQuery[ExpectType]]") [return-value]
src/textual/widget.py:433: error: "DOMNode" has no attribute "get_child_by_id" [attr-defined]
src/textual/widget.py:706: error: Argument 1 to "_to_widget" has incompatible type "Union[int, Widget, None]"; expected "Union[int, Widget]" [arg-type]
Expand Down Expand Up @@ -62,4 +60,4 @@ src/textual/demo.py:221: error: "App[Any]" has no attribute "add_note" [attr-de
src/textual/demo.py:276: error: "App[Any]" has no attribute "add_note" [attr-defined]
src/textual/cli/previews/easing.py:102: error: Argument "easing" to "animate" of "App" has incompatible type "Optional[str]"; expected "Union[Callable[[float], float], str]" [arg-type]
src/textual/cli/previews/easing.py:111: error: "MessageTarget" has no attribute "id" [attr-defined]
Found 62 errors in 16 files (checked 152 source files)
Found 60 errors in 15 files (checked 152 source files)
5 changes: 2 additions & 3 deletions src/textual/css/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def substitute_references(

iter_tokens = iter(tokens)

while tokens:
while True:
token = next(iter_tokens, None)
if token is None:
break
Expand All @@ -274,8 +274,7 @@ def substitute_references(

while True:
token = next(iter_tokens, None)
# TODO: Mypy error looks legit
if token.name == "whitespace":
if token is not None and token.name == "whitespace":
yield token
else:
break
Expand Down

0 comments on commit 4cea32d

Please sign in to comment.