diff --git a/mypy.txt b/mypy.txt index 6cd28f27d8..7834b6fb6e 100644 --- a/mypy.txt +++ b/mypy.txt @@ -3,9 +3,7 @@ src/textual/_two_way_dict.py:41: error: Incompatible return value type (got "Opt src/textual/_two_way_dict.py:52: error: Incompatible return value type (got "Optional[Key]", expected "Key") [return-value] src/textual/devtools/service.py:10: error: Skipping analyzing "msgpack": module is installed, but missing library stubs or py.typed marker [import] src/textual/devtools/client.py:13: error: Skipping analyzing "msgpack": module is installed, but missing library stubs or py.typed marker [import] -src/textual/devtools/redirect_output.py:42: error: Item "None" of "Optional[FrameType]" has no attribute "f_back" [union-attr] -src/textual/devtools/redirect_output.py:43: error: Argument 1 to "getframeinfo" has incompatible type "Union[FrameType, None, Any]"; expected "Union[FrameType, TracebackType]" [arg-type] -src/textual/devtools/redirect_output.py:45: error: Argument "caller" to "DevtoolsLog" has incompatible type "Traceback"; expected "FrameInfo" [arg-type] +src/textual/devtools/redirect_output.py:48: error: Argument "caller" to "DevtoolsLog" has incompatible type "Traceback"; expected "FrameInfo" [arg-type] src/textual/__init__.py:27: error: Library stubs not installed for "pkg_resources" [import] src/textual/__init__.py:27: note: Hint: "python3 -m pip install types-setuptools" src/textual/__init__.py:27: note: (or run "mypy --install-types" to install all missing stub packages) @@ -92,4 +90,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 84 errors in 28 files (checked 152 source files) +Found 82 errors in 28 files (checked 152 source files) diff --git a/src/textual/devtools/redirect_output.py b/src/textual/devtools/redirect_output.py index b79f935805..0e1f934b2e 100644 --- a/src/textual/devtools/redirect_output.py +++ b/src/textual/devtools/redirect_output.py @@ -39,7 +39,10 @@ def write(self, string: str) -> None: if not self.devtools.is_connected: return - previous_frame = inspect.currentframe().f_back + current_frame = inspect.currentframe() + assert current_frame is not None + previous_frame = current_frame.f_back + assert previous_frame is not None caller = inspect.getframeinfo(previous_frame) self._buffer.append(DevtoolsLog(string, caller=caller)) diff --git a/src/textual/devtools/service.py b/src/textual/devtools/service.py index 5e85d2f895..f3c3f19f77 100644 --- a/src/textual/devtools/service.py +++ b/src/textual/devtools/service.py @@ -5,10 +5,10 @@ import json import pickle from json import JSONDecodeError -from typing import Any, cast +from typing import Any import msgpack -from aiohttp import WSMessage, WSMsgType +from aiohttp import WSMsgType from aiohttp.abc import Request from aiohttp.web_ws import WebSocketResponse from rich.console import Console