Skip to content
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

chore: add script for running mypy type checks and speed up mypy checks in CI jobs #17489

Merged
merged 1 commit into from
Apr 9, 2025

Conversation

bowenliang123
Copy link
Contributor

@bowenliang123 bowenliang123 commented Apr 6, 2025

Summary

Installing collected packages: lxml-stubs, types-ujson, types-six, types-simplejson, types-shapely, types-requests, types-regex, types-PyYAML, types-pywin32, types-python-dateutil, types-PyMySQL, types-psycopg2, types-psutil, types-protobuf, types-pexpect, types-openpyxl, types-olefile, types-objgraph, types-oauthlib, types-Markdown, types-html5lib, types-greenlet, types-docutils, types-Deprecated, types-defusedxml, types-colorama, types-cachetools, types-aiofiles, types-tqdm, types-tensorflow, types-requests-oauthlib, types-Pygments, types-gevent, types-beautifulsoup4, types-Flask-Cors, types-Flask-Migrate
Successfully installed lxml-stubs-0.5.1 types-Deprecated-1.2.15.20250304 types-Flask-Cors-5.0.0.20240902 types-Flask-Migrate-4.1.0.20250112 types-Markdown-3.7.0.20250322 types-PyMySQL-1.1.0.20241103 types-PyYAML-6.0.12.20250402 types-Pygments-2.19.0.20250305 types-aiofiles-24.1.0.20250326 types-beautifulsoup4-4.12.0.20250204 types-cachetools-5.5.0.20240820 types-colorama-0.4.15.20240311 types-defusedxml-0.7.0.20240218 types-docutils-0.21.0.20241128 types-gevent-24.11.0.20250401 types-greenlet-3.1.0.20250401 types-html5lib-1.1.11.20241018 types-oauthlib-3.2.0.20250403 types-objgraph-3.6.0.20240907 types-olefile-0.47.0.20240806 types-openpyxl-3.1.5.20250306 types-pexpect-4.9.0.20241208 types-protobuf-5.29.1.20250403 types-psutil-7.0.0.20250401 types-psycopg2-2.9.21.20250318 types-python-dateutil-2.9.0.20241206 types-pywin32-310.0.0.20250319 types-regex-2024.11.6.20250403 types-requests-2.32.0.20250328 types-requests-oauthlib-2.0.0.20250306 types-shapely-2.0.0.20250404 types-simplejson-3.20.0.20250326 types-six-1.17.0.20250403 types-tensorflow-2.18.0.20250404 types-tqdm-4.67.0.20250404 types-ujson-5.10.0.20250326

Screenshots

Before After
... ...

Checklist

Important

Please review the checklist below before submitting your pull request.

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

@bowenliang123 bowenliang123 force-pushed the mypy-script branch 3 times, most recently from 12bebe5 to 076431d Compare April 6, 2025 12:57
@bowenliang123 bowenliang123 changed the title [WIP] chore: add script for running mypy checks and simplify type dependencies chore: add script for running mypy type checks and remove stub type dependencies Apr 6, 2025
@bowenliang123 bowenliang123 marked this pull request as ready for review April 6, 2025 14:23
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. dependencies Pull requests that update a dependency file labels Apr 6, 2025
@bowenliang123
Copy link
Contributor Author

cc @laipz8200

@laipz8200
Copy link
Member

if you remove stubs from the lock file, they will be removed when you run poetry sync.

@bowenliang123
Copy link
Contributor Author

With the latest dev script to rerun the mypy checks, all the required stub dependencies will be automately installed again from pip cache, which takes very little time. It's also worth to pay attention is that currently pinned sub versions in pyproject.toml and the Poetry lockfile are not fully satisfied for mypy checks, and there still requires auto installing in testing runtime.

@bowenliang123
Copy link
Contributor Author

Or shall I leave the stub versions pinned, and only adding the script to run mypy checks? I'll follow your advice.

@bowenliang123
Copy link
Contributor Author

bowenliang123 commented Apr 7, 2025

Hi @laipz8200 , after the offline disscussion with you, I have completed these changes:

  • bring back and update the list and version of stub file dependencies to pyproject.toml and poetry.lock
  • append the execution of dev/run-py scirpt in dev/reformat script

And the time cost of the repeated mypy checks in CI workflow has been shrinked down to 3-5 seconds, with stub files installed and properly cached mypy files.

@bowenliang123 bowenliang123 changed the title chore: add script for running mypy type checks and remove stub type dependencies chore: add script for running mypy type checks and speed up mypy checks in CI jobs Apr 7, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 9, 2025
@laipz8200 laipz8200 merged commit 0b1259f into langgenius:main Apr 9, 2025
8 checks passed
@bowenliang123 bowenliang123 deleted the mypy-script branch April 9, 2025 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide development script for running Mypy type checks and remove pinned stub dependencies version
2 participants