Surprisingly long CI (github-actions) mypy execution time
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Hey folks,
I guess this is a wrong place to post it, though at this point I kinda feel helpless and I won't get any substantial insights on StackOverflow. What's the story then? I've started working on some kaggle project with a friend using a fresh repo. We use mypy in our CI build pipeline. At some point github actions started reporting really long execution times on mypy step. Running mypy locally takes barely seconds as it's still very small repo. Let me show you one of them:

mypy takes almost 2 minutes for just a few files in a repo. Setting up python 3.10 takes considerable time, but it's mostly recovering poetry cache with some heavy libraries. That's ok. At first I thought we might have some problems using --install-types flag but that's not a case. I went throught the CI history and found out that mypy execution time went up, once we added pytorch to the project's dependencies. I guess mypy is running some type resolution/discovery stuff for used dependencies. Is there any way to cache it in a remote CI setting to reduce the execution times?
repo: https://github.com/piotr-rarus/kaggle-rsna-breast-cancer
build workflow: https://github.com/piotr-rarus/kaggle-rsna-breast-cancer/blob/main/.github/workflows/build.yml
- name: Mypy
run: |
poetry run mypy --incremental --show-error-codes --pretty src
All relevant env info is stated in the repo's toml. Dependencies are managed using poetry and pinned down in poetry.lock: https://github.com/piotr-rarus/kaggle-rsna-breast-cancer/blob/main/pyproject.toml
By no means I expect to get a fix, that's not a bug. Some substantial insights into proper CI mypy usage would be most welcome :)
Take care, you're my favourite python's lib.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with .github/workflows/build.yml and pyproject.toml, then compare the workflow's mypy step with the repository's dependency and cache configuration. Investigate the reported timing increase after adding pytorch and determine whether the result supports a documented CI usage or caching recommendation; the issue is done when that guidance is clearly recorded or the question is resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions, python, pytorch
- Domain
- ci-cd, tooling
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100