From bdac4161af689da446f892e05c11c49c26ea75cf Mon Sep 17 00:00:00 2001 From: Archmonger <16909269+Archmonger@users.noreply.github.com> Date: Tue, 11 Feb 2025 23:05:07 -0800 Subject: [PATCH 1/9] `pragma` to `nocov` --- src/reactpy/core/_life_cycle_hook.py | 2 +- src/reactpy/core/_thread_local.py | 2 +- src/reactpy/core/hooks.py | 2 +- src/reactpy/executors/asgi/middleware.py | 6 ++--- src/reactpy/executors/asgi/pyscript.py | 4 +-- src/reactpy/executors/asgi/standalone.py | 2 +- src/reactpy/executors/utils.py | 2 +- src/reactpy/pyscript/utils.py | 2 +- src/reactpy/templatetags/jinja.py | 2 +- src/reactpy/testing/display.py | 2 +- src/reactpy/testing/utils.py | 2 +- tests/test_utils.py | 31 ------------------------ 12 files changed, 13 insertions(+), 46 deletions(-) diff --git a/src/reactpy/core/_life_cycle_hook.py b/src/reactpy/core/_life_cycle_hook.py index 8600b3f01..c940bf01b 100644 --- a/src/reactpy/core/_life_cycle_hook.py +++ b/src/reactpy/core/_life_cycle_hook.py @@ -22,7 +22,7 @@ async def __call__(self, stop: Event) -> None: ... logger = logging.getLogger(__name__) -class _HookStack(Singleton): # pragma: no cover +class _HookStack(Singleton): # nocov """A singleton object which manages the current component tree's hooks. Life cycle hooks can be stored in a thread local or context variable depending on the platform.""" diff --git a/src/reactpy/core/_thread_local.py b/src/reactpy/core/_thread_local.py index 0d83f7e41..eb582e8e8 100644 --- a/src/reactpy/core/_thread_local.py +++ b/src/reactpy/core/_thread_local.py @@ -5,7 +5,7 @@ _StateType = TypeVar("_StateType") -class ThreadLocal(Generic[_StateType]): # pragma: no cover +class ThreadLocal(Generic[_StateType]): # nocov """Utility for managing per-thread state information. This is only used in environments where ContextVars are not available, such as the `pyodide` executor.""" diff --git a/src/reactpy/core/hooks.py b/src/reactpy/core/hooks.py index a0a4e161c..d2dcea8e7 100644 --- a/src/reactpy/core/hooks.py +++ b/src/reactpy/core/hooks.py @@ -613,7 +613,7 @@ def strictly_equal(x: Any, y: Any) -> bool: return x == y # type: ignore # Fallback to identity check - return x is y # pragma: no cover + return x is y # nocov def run_effect_cleanup(cleanup_func: Ref[_EffectCleanFunc | None]) -> None: diff --git a/src/reactpy/executors/asgi/middleware.py b/src/reactpy/executors/asgi/middleware.py index 54b8df511..976119c8f 100644 --- a/src/reactpy/executors/asgi/middleware.py +++ b/src/reactpy/executors/asgi/middleware.py @@ -166,7 +166,7 @@ async def __call__( msg: dict[str, str] = orjson.loads(event["text"]) if msg.get("type") == "layout-event": await ws.rendering_queue.put(msg) - else: # pragma: no cover + else: # nocov await asyncio.to_thread( _logger.warning, f"Unknown message type: {msg.get('type')}" ) @@ -205,7 +205,7 @@ async def run_dispatcher(self) -> None: # Determine component to serve by analyzing the URL and/or class parameters. if self.parent.multiple_root_components: url_match = re.match(self.parent.dispatcher_pattern, self.scope["path"]) - if not url_match: # pragma: no cover + if not url_match: # nocov raise RuntimeError("Could not find component in URL path.") dotted_path = url_match["dotted_path"] if dotted_path not in self.parent.root_components: @@ -215,7 +215,7 @@ async def run_dispatcher(self) -> None: component = self.parent.root_components[dotted_path] elif self.parent.root_component: component = self.parent.root_component - else: # pragma: no cover + else: # nocov raise RuntimeError("No root component provided.") # Create a connection object by analyzing the websocket's query string. diff --git a/src/reactpy/executors/asgi/pyscript.py b/src/reactpy/executors/asgi/pyscript.py index 79ccfb2ad..b3f2cd38f 100644 --- a/src/reactpy/executors/asgi/pyscript.py +++ b/src/reactpy/executors/asgi/pyscript.py @@ -79,9 +79,7 @@ def __init__( self.html_head = html_head or html.head() self.html_lang = html_lang - def match_dispatch_path( - self, scope: AsgiWebsocketScope - ) -> bool: # pragma: no cover + def match_dispatch_path(self, scope: AsgiWebsocketScope) -> bool: # nocov """We do not use a WebSocket dispatcher for Client-Side Rendering (CSR).""" return False diff --git a/src/reactpy/executors/asgi/standalone.py b/src/reactpy/executors/asgi/standalone.py index 56c7f6367..1a8caad2f 100644 --- a/src/reactpy/executors/asgi/standalone.py +++ b/src/reactpy/executors/asgi/standalone.py @@ -182,7 +182,7 @@ class ReactPyApp: async def __call__( self, scope: AsgiScope, receive: AsgiReceive, send: AsgiSend ) -> None: - if scope["type"] != "http": # pragma: no cover + if scope["type"] != "http": # nocov if scope["type"] != "lifespan": msg = ( "ReactPy app received unsupported request of type '%s' at path '%s'", diff --git a/src/reactpy/executors/utils.py b/src/reactpy/executors/utils.py index e29cdf5c6..03006a3ef 100644 --- a/src/reactpy/executors/utils.py +++ b/src/reactpy/executors/utils.py @@ -25,7 +25,7 @@ def import_components(dotted_paths: Iterable[str]) -> dict[str, Any]: } -def check_path(url_path: str) -> str: # pragma: no cover +def check_path(url_path: str) -> str: # nocov """Check that a path is valid URL path.""" if not url_path: return "URL path must not be empty." diff --git a/src/reactpy/pyscript/utils.py b/src/reactpy/pyscript/utils.py index eb277cfb5..ed115e346 100644 --- a/src/reactpy/pyscript/utils.py +++ b/src/reactpy/pyscript/utils.py @@ -144,7 +144,7 @@ def extend_pyscript_config( return orjson.dumps(pyscript_config).decode("utf-8") -def reactpy_version_string() -> str: # pragma: no cover +def reactpy_version_string() -> str: # nocov from reactpy.testing.common import GITHUB_ACTIONS local_version = reactpy.__version__ diff --git a/src/reactpy/templatetags/jinja.py b/src/reactpy/templatetags/jinja.py index 672089752..c4256b525 100644 --- a/src/reactpy/templatetags/jinja.py +++ b/src/reactpy/templatetags/jinja.py @@ -22,7 +22,7 @@ def render(self, *args: str, **kwargs: str) -> str: return pyscript_setup(*args, **kwargs) # This should never happen, but we validate it for safety. - raise ValueError(f"Unknown tag: {self.tag_name}") # pragma: no cover + raise ValueError(f"Unknown tag: {self.tag_name}") # nocov def component(dotted_path: str, **kwargs: str) -> str: diff --git a/src/reactpy/testing/display.py b/src/reactpy/testing/display.py index e3aced083..aeaf6a34d 100644 --- a/src/reactpy/testing/display.py +++ b/src/reactpy/testing/display.py @@ -58,7 +58,7 @@ async def __aenter__(self) -> DisplayFixture: self.page.set_default_timeout(REACTPY_TESTS_DEFAULT_TIMEOUT.current * 1000) - if not hasattr(self, "backend"): # pragma: no cover + if not hasattr(self, "backend"): # nocov self.backend = BackendFixture() await es.enter_async_context(self.backend) diff --git a/src/reactpy/testing/utils.py b/src/reactpy/testing/utils.py index f1808022c..6a48516ed 100644 --- a/src/reactpy/testing/utils.py +++ b/src/reactpy/testing/utils.py @@ -7,7 +7,7 @@ def find_available_port( host: str, port_min: int = 8000, port_max: int = 9000 -) -> int: # pragma: no cover +) -> int: # nocov """Get a port that's available for the given host and port range""" for port in range(port_min, port_max): with closing(socket.socket()) as sock: diff --git a/tests/test_utils.py b/tests/test_utils.py index fbc1b7112..e7728f902 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -153,37 +153,6 @@ def test_html_to_vdom_with_no_parent_node(): assert utils.html_to_vdom(source) == expected -def test_del_html_body_transform(): - source = """ - - - -
-