-
Notifications
You must be signed in to change notification settings - Fork 100
[regression] Mypy fails with shiny==0.9.0
#1332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I made a quick fix in 94d84c3. We currently use pyright in strict mode for type checking this project. In my opinion, pyright works much better in my than mypy. In theory, type checking with mypy in CI would be good, to avoid problems like the one that you ran into, where a project that that imports shiny makes use of On the Shiny code base, pyright reports zero type errors, but mypy reports 180 errors. I don't think getting it to pass both systems would not make the code meaningfully better. The change I made in 94d84c3 fixed the syntax error, but mypy still thinks there are type errors. Hopefully fixing just the syntax error is enough to satisfy the use case you have run into. |
Thanks for the fix. Hmm, I personally don't personally like the fact that As you mentioned, making |
It would be nice if it were as simple as having an If it were possible to run |
The same problem re-appeared on Looks like some work in the mypy codebase has been done to try ignore the error above, but it's currently still not fixed. Currently one way to check for this specific issue would be to run: |
@gabrielecalvo Do you know which lines in the Shiny code base cause the problems with mypy? |
yep, it's the same one as before actually.. $ mypy app.py
.venv\Lib\site-packages\shiny\render\_data_frame_utils\_selection.py:154: error: invalid syntax [syntax]
Found 1 error in 1 file (errors prevented further checking) (using current latest versions mypy==1.11.1 and shiny==1.0.0) |
Hi,
I've found the following regression.
Problem
With
mypy==1.9.0
andshiny==0.9.0
andin
app.py
.mypy app.py
raisesThis doesn't happen with
shiny==0.8.1
, I get the expectedSuccess: 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: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 maybeLiteral["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
The text was updated successfully, but these errors were encountered: