From 74baf8333617d27e412ae612d5c02c5f8d6b6753 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Mon, 7 Oct 2024 12:10:55 -0400 Subject: [PATCH] Updates for pyright rules; Motivation to gut output_transformer --- shiny/_utils.py | 2 +- tests/playwright/shiny/components/data_frame/edit/app.py | 6 +++++- .../data_frame/styles/great_tables_test_utils.py | 8 ++++++-- .../playwright/shiny/deprecated/output_transformer/app.py | 6 ++++++ tests/playwright/shiny/server/output_transformer/app.py | 5 +++++ tests/pytest/test_output_transformer.py | 6 ++++++ 6 files changed, 29 insertions(+), 4 deletions(-) diff --git a/shiny/_utils.py b/shiny/_utils.py index aff24044b..a52997d72 100644 --- a/shiny/_utils.py +++ b/shiny/_utils.py @@ -85,7 +85,7 @@ def guess_mime_type( if url: # Work around issue #1601, some installations of Windows 10 return text/plain # as the mime type for .js files - _, ext = os.path.splitext(os.fspath(url)) + _, ext = os.path.splitext(os.fspath(str(url))) if ext.lower() in [".js", ".mjs", ".cjs"]: return "text/javascript" return mimetypes.guess_type(url, strict)[0] or default diff --git a/tests/playwright/shiny/components/data_frame/edit/app.py b/tests/playwright/shiny/components/data_frame/edit/app.py index c759bf9d7..2f8707e39 100644 --- a/tests/playwright/shiny/components/data_frame/edit/app.py +++ b/tests/playwright/shiny/components/data_frame/edit/app.py @@ -89,7 +89,11 @@ def gt_styles(df_gt: gt.GT) -> list[StyleInfo]: ret: list[StyleInfo] = [] for style in styles: location = style.locname - location = "body" if location == "data" else location + location = ( + "body" + if location == "data" # pyright: ignore[reportUnnecessaryComparison] + else location + ) assert location == "body", f"`style.locname` is {location}, expected 'body'" rows = style.rownum assert rows is not None diff --git a/tests/playwright/shiny/components/data_frame/styles/great_tables_test_utils.py b/tests/playwright/shiny/components/data_frame/styles/great_tables_test_utils.py index eb0213417..3ec41f236 100644 --- a/tests/playwright/shiny/components/data_frame/styles/great_tables_test_utils.py +++ b/tests/playwright/shiny/components/data_frame/styles/great_tables_test_utils.py @@ -23,7 +23,11 @@ def gt_styles(df_gt: gt.GT) -> list[StyleInfo]: ret: list[StyleInfo] = [] for style in styles: location = style.locname - location = "body" if location == "data" else location + location = ( + "body" + if location == "data" # pyright: ignore[reportUnnecessaryComparison] + else location + ) assert location == "body", f"`style.locname` is {location}, expected 'body'" rows = style.rownum assert rows is not None @@ -39,7 +43,7 @@ def gt_styles(df_gt: gt.GT) -> list[StyleInfo]: ) ret.append( { - "location": location, + "location": location, # pyright: ignore[reportArgumentType] "rows": rows, "cols": cols, "style": style_obj, diff --git a/tests/playwright/shiny/deprecated/output_transformer/app.py b/tests/playwright/shiny/deprecated/output_transformer/app.py index 725d9f6f1..3ec9dfe38 100644 --- a/tests/playwright/shiny/deprecated/output_transformer/app.py +++ b/tests/playwright/shiny/deprecated/output_transformer/app.py @@ -1,3 +1,9 @@ +# pyright: reportUntypedFunctionDecorator=false +# pyright: reportUnknownParameterType=false +# pyright: reportUnknownMemberType=false +# pyright: reportInvalidTypeForm=false +# pyright: reportUnknownArgumentType=false +# pyright: reportArgumentType=false from __future__ import annotations import warnings diff --git a/tests/playwright/shiny/server/output_transformer/app.py b/tests/playwright/shiny/server/output_transformer/app.py index 8c988cc62..37d1063dc 100644 --- a/tests/playwright/shiny/server/output_transformer/app.py +++ b/tests/playwright/shiny/server/output_transformer/app.py @@ -1,3 +1,8 @@ +# pyright: reportUntypedFunctionDecorator=false +# pyright: reportUnknownMemberType=false +# pyright: reportInvalidTypeForm=false +# pyright: reportUnknownParameterType=false +# pyright: reportUnknownArgumentType=false from __future__ import annotations from typing import Optional, overload diff --git a/tests/pytest/test_output_transformer.py b/tests/pytest/test_output_transformer.py index 0ae494b0c..afd69811a 100644 --- a/tests/pytest/test_output_transformer.py +++ b/tests/pytest/test_output_transformer.py @@ -1,3 +1,9 @@ +# pyright: reportUnknownParameterType=false +# pyright: reportUnknownMemberType=false +# pyright: reportInvalidTypeForm=false +# pyright: reportUntypedFunctionDecorator=false +# pyright: reportUnknownArgumentType=false +# pyright: reportFunctionMemberAccess=false from __future__ import annotations import asyncio