-
-
Notifications
You must be signed in to change notification settings - Fork 340
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
Run mypy on CI, fix or ignore typing issues #987
Conversation
f64bd7e
to
a2e9890
Compare
@krassowski Thank you for this significant contribution! This was on our to-do list for a while but we never managed to get around to it. Since this is a large PR that changes many type hints that |
@dlqqq If you mean the ellipses, I think that is a straightforward change. Quoting from pydantic documentation (emphasis mine):
https://docs.pydantic.dev/latest/concepts/models/#field-ordering |
to be clear, this is verbatim from the latest v2 documentation so should be taken as applying to both v1 and v2 :) |
There's an unrelated error in CI for the E2E tests workflow:
I'm looking into this now and will open a separate PR to address this. |
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.
This PR looks good to me! However, when I run mypy
locally, I get an error regarding the deepmerge
package being untyped, even though the same check passes in CI. I'm using mypy 1.11.2
, same as the CI env. Not sure what could be causing this 🤔
% mypy packages/jupyter-ai
packages/jupyter-ai/jupyter_ai/config_manager.py:8: error: Skipping analyzing "deepmerge": module is installed, but missing library stubs or py.typed marker [import-untyped]
packages/jupyter-ai/jupyter_ai/config_manager.py:8: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
packages/jupyter-ai/jupyter_ai/handlers.py:556: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked]
packages/jupyter-ai/jupyter_ai/extension.py:393: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked]
packages/jupyter-ai/jupyter_ai/extension.py:420: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked]
Found 1 error in 1 file (checked 27 source files)
% mypy --version
mypy 1.11.2 (compiled: yes)
You need to update |
See toumorokoshi/deepmerge#30 - this was merged 8 months ago. I also had an old version in my dev env :) |
@krassowski Awesome, thanks for finding that reference so quickly! One remaining question: Should we bump the version specifier on deepmerge and require |
My thinking was that an update was not needed because end users do not care about mypy checks on CI, and developers will not get it auto-updated when they pull changes either (unless they reinstall the environment). I wonder if it should have an upper bound on <3 just to ensure a future release does not break installation. But if you think it is worth pinning the floor, then let's do that! |
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.
Thank you for your contribution & your suggestions! I've bumped the version floor and added a version ceiling in the latest commit. Everything looks good. Will merge pending green CI.
* Run mypy on CI * Rename, add mypy to test deps * Fix typing jupyter-ai codebase (mostly) * Three more cases * update deepmerge version specifier --------- Co-authored-by: David L. Qiu <[email protected]>
* Run mypy on CI * Rename, add mypy to test deps * Fix typing jupyter-ai codebase (mostly) * Three more cases * update deepmerge version specifier --------- Co-authored-by: David L. Qiu <[email protected]>
* Run mypy on CI * Rename, add mypy to test deps * Fix typing jupyter-ai codebase (mostly) * Three more cases * update deepmerge version specifier --------- Co-authored-by: David L. Qiu <[email protected]>
* Run mypy on CI * Rename, add mypy to test deps * Fix typing jupyter-ai codebase (mostly) * Three more cases * update deepmerge version specifier --------- Co-authored-by: David L. Qiu <[email protected]>
* context provider * split base and base command context providers + replacing prompt * comment * only replace prompt if context variable in template * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Run mypy on CI, fix or ignore typing issues (#987) * Run mypy on CI * Rename, add mypy to test deps * Fix typing jupyter-ai codebase (mostly) * Three more cases * update deepmerge version specifier --------- Co-authored-by: David L. Qiu <[email protected]> * context provider * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * mypy * black * modify backtick logic * allow for spaces in filepath * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * refactor * fixes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix test * refactor autocomplete to remove hardcoded '/' and '@' prefix * modify context prompt template Co-authored-by: david qiu <[email protected]> * refactor * docstrings + refactor * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * mypy * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add context providers to help * remove _examples.py and remove @learned from defaults * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * make find_commands unoverridable --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Michał Krassowski <[email protected]> Co-authored-by: David L. Qiu <[email protected]>
* Run mypy on CI * Rename, add mypy to test deps * Fix typing jupyter-ai codebase (mostly) * Three more cases * update deepmerge version specifier --------- Co-authored-by: David L. Qiu <[email protected]>
* context provider * split base and base command context providers + replacing prompt * comment * only replace prompt if context variable in template * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Run mypy on CI, fix or ignore typing issues (jupyterlab#987) * Run mypy on CI * Rename, add mypy to test deps * Fix typing jupyter-ai codebase (mostly) * Three more cases * update deepmerge version specifier --------- Co-authored-by: David L. Qiu <[email protected]> * context provider * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * mypy * black * modify backtick logic * allow for spaces in filepath * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * refactor * fixes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix test * refactor autocomplete to remove hardcoded '/' and '@' prefix * modify context prompt template Co-authored-by: david qiu <[email protected]> * refactor * docstrings + refactor * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * mypy * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add context providers to help * remove _examples.py and remove @learned from defaults * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * make find_commands unoverridable --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Michał Krassowski <[email protected]> Co-authored-by: David L. Qiu <[email protected]>
Fixes #985
For now this only runs mypy on
jupyter-ai
but not yet onjupyter-ai-magics
(which we may decide to add in a separate PR).