Skip to content

[regression] Mypy fails with shiny==0.9.0 #1332

Closed
@pstorozenko

Description

@pstorozenko

Hi,
I've found the following regression.

Problem

With mypy==1.9.0 and shiny==0.9.0 and

import shiny

in app.py.

mypy app.py raises

➜ mypy app.py
/Users/pasza/Library/Caches/pypoetry/virtualenvs/test-shiny09-qk-unJu3-py3.12/lib/python3.12/site-packages/shiny/render/_data_frame_utils/_selection.py:155: error: invalid syntax  [syntax]
Found 1 error in 1 file (errors prevented further checking)

This doesn't happen with shiny==0.8.1, I get the expected Success: no issues found in 1 source file.

Reason

The reason is the commented-out code in the source code 🙈
In _selection.py, lines 154-155 are:

# class CellSelectionAll(TypedDict):
#     type: Literal["all"]

mypy (I guess) interprets # type: as some kind of type hint for the thing in front of the # sign. Or something like that, just like # type: ignore. Or maybe Literal["all"] is just not proper syntax for # type:...

Potential fix

Remove unused code, or mangle the commented code to not make it clash with mypy.

After thought

Maybe this check could've/should've been added to CICD?

Best,
Pasza

[tool.poetry]
name = "test-shiny09"
version = "0.1.0"
description = ""
authors = ["Piotr Pasza Storozenko <piotr@appsilon.com>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.12"
shiny = "0.9.0"
mypy = "^1.9.0"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions