-
-
Notifications
You must be signed in to change notification settings - Fork 530
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
Enable using mypy manually #7081
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7081 +/- ##
==========================================
- Coverage 82.22% 82.21% -0.02%
==========================================
Files 326 326
Lines 48536 48536
==========================================
- Hits 39908 39903 -5
- Misses 8628 8633 +5 ☔ View full report in Codecov by Sentry. |
d9effd6
to
7150ff4
Compare
I pushed some changes so we can see the result of type checking in the CI. I have set the CI to never fail, but this should be removed at some point. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this works, however I think what you choose to run depends on what you are looking to do. My original issue was concerned primarily with the public API, and to run Mypy on the files changed would also be checking elements of the private API and library internals.
Ideally, you would want to run Mypy on panel itself and check for / catch issues / validate annotations, but that would expose a larger number of errors to fix.
If we want to check the public API, I think the best thing would be to run mypy in strict
mode on the examples
folder, and when all the issues are fixed, adding it to the CI as well.
…oloviz/panel into enhancement/enable-manual-mypy
namespace_packages = true | ||
explicit_package_bases = true | ||
mypy_path = "" | ||
exclude = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran Mypy in the same way you were @MarcSkovMadsen and I got a bunch of additional errors on unrelated files. At least for now, maybe it's worth turning off the unrelated file errors?
exclude = [] | |
exclude = [] | |
follow_imports = "silent" |
From https://mypy.readthedocs.io/en/stable/running_mypy.html#following-imports:
If you are starting a new codebase and plan on using type hints from the start, we recommend you use either --follow-imports=normal (the default) or --follow-imports=error. Either option will help make sure you are not skipping checking any part of your codebase by accident.
If you are planning on adding type hints to a large, existing code base, we recommend you start by trying to make your entire codebase (including files that do not use type hints) pass under --follow-imports=normal. This is usually not too difficult to do: mypy is designed to report as few error messages as possible when it is looking at unannotated code.
Only if doing this is intractable, we recommend passing mypy just the files you want to type check and use --follow-imports=silent. Even if mypy is unable to perfectly type check a file, it can still glean some useful information by parsing it (for example, understanding what methods a given object has). See Using mypy with an existing codebase for more recommendations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should change it with the argument that what we want to check in the pipeline is everything as that is the end goal for the Panel project to have no issues whether internal facing or external facing.
I believe for "the current effort" which is focused on outward facing api we should add the relevant settings via flags manually when running mypy manually. Makes sense?
…his1/panel into enhancement/enable-manual-mypy
Co-authored-by: Simon Høxbro Hansen <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
In #7079, @gandhis1 contributes a typing improvement. In order to be able to review this PR I would like to run
mypy
.This PR configures the project in such a way that you can
pip install -e .[mypy]
to install themypy
dependenciesmypy path/to/file.py
to check a specific file.It removes the errors raised about missing stubs and dependencies that do not support typing.