Giter Club home page Giter Club logo

Comments (3)

wch avatar wch commented on July 18, 2024 2

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 mypy to do type checking. However, I don't think that using mypy in addition to pyright is practical for Shiny, because there are differences in the behavior of mypy and pyright, as documented here:
https://github.com/microsoft/pyright/blob/main/docs/mypy-comparison.md

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.

from py-shiny.

wch avatar wch commented on July 18, 2024 1

It would be nice if it were as simple as having an app.py with import shiny in it, like in your case. However, there are a number submodules which are not automatically loaded this way, and so they would not be "tested" for syntax errors under mypy.

If it were possible to run mypy on the whole shiny codebase and report only mypy syntax errors, that is probably what we would want. However, I took a quick look at the mypy documentation and did not see a way to check only for mypy syntax errors. If you know of a way to do that, please let us know.

from py-shiny.

pstorozenko avatar pstorozenko commented on July 18, 2024

Thanks for the fix.

Hmm, I personally don't personally like the fact that pyright has js dependencies and always preferred mypy for CI/CD (I use pyright in vs code), but it's good to know shiny has pyright-first support when it comes to type checking, thanks.

As you mentioned, making shiny internal code base pass both systems doesn't make sense to me neither, but making sure that mypy users can just import shiny without problems in their code base could be beneficial.

from py-shiny.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.