Skip to content

Commit

Permalink
Updates for pyright rules; Motivation to gut output_transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
schloerke committed Oct 7, 2024
1 parent 142aa70 commit 74baf83
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion shiny/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion tests/playwright/shiny/components/data_frame/edit/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions tests/playwright/shiny/deprecated/output_transformer/app.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions tests/playwright/shiny/server/output_transformer/app.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 6 additions & 0 deletions tests/pytest/test_output_transformer.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 74baf83

Please sign in to comment.