Skip to content

ci: run mypy across the codebase#9103

Merged
anakin87 merged 5 commits intomainfrom
always-run-mypy
Mar 25, 2025
Merged

ci: run mypy across the codebase#9103
anakin87 merged 5 commits intomainfrom
always-run-mypy

Conversation

@anakin87
Copy link
Copy Markdown
Member

@anakin87 anakin87 commented Mar 24, 2025

Related Issues

Proposed Changes:

  • whenever at least one python file is changed, make mypy run across all the codebase

How did you test it?

CI; triggered a run by temporarily changing a python file (9b5457a) -> mypy run (failures in the logs are related to #9102)

In this case, mypy spent 1m22s (for comparison, in #9099, mypy ran on a single file and took 1m5s).

Notes for the reviewer

Perhaps we have not done this in the past because mypy is slow...
However, the lint job (including mypy) depends on unit tests and runs concurrently with integration tests (which are slower), so all in all I don't think this change would make people wait any longer.

Checklist

  • I have read the contributors guidelines and the code of conduct
  • I have updated the related issue with new insights and changes
  • I added unit tests and updated the docstrings
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I documented my code
  • I ran pre-commit hooks and fixed any issue

@anakin87 anakin87 marked this pull request as ready for review March 24, 2025 18:17
@anakin87 anakin87 requested a review from a team as a code owner March 24, 2025 18:17
@anakin87 anakin87 requested review from davidsbatista and removed request for a team March 24, 2025 18:17
@vblagoje
Copy link
Copy Markdown
Member

Interesting that the difference is so small

@coveralls
Copy link
Copy Markdown
Collaborator

Pull Request Test Coverage Report for Build 14042523294

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 90.131%

Totals Coverage Status
Change from base Build 14042052718: 0.0%
Covered Lines: 9854
Relevant Lines: 10933

💛 - Coveralls

@coveralls
Copy link
Copy Markdown
Collaborator

Pull Request Test Coverage Report for Build 14042532370

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 90.131%

Totals Coverage Status
Change from base Build 14042052718: 0.0%
Covered Lines: 9854
Relevant Lines: 10933

💛 - Coveralls

@davidsbatista
Copy link
Copy Markdown
Contributor

In this case, mypy spent 1m22s (for comparison, in #9099, mypy ran on a single file and took 1m5s).

This seems to be a too-small difference between running mypy over the whole code base and a single file - are you sure no caching was being used?

I would say we should only run a type checker over the changed files and the over whole code base when, for instance, mypy is updated.

@vblagoje @julian-risch what do you think?

@anakin87
Copy link
Copy Markdown
Member Author

anakin87 commented Mar 25, 2025

This seems to be a too-small difference between running mypy over the whole code base and a single file - are you sure no caching was being used?

I would say we should only run a type checker over the changed files and the over whole code base when, for instance, mypy is updated.

I'd propose always running mypy across the entire codebase for two reasons:

  • if we change something in a core class and then run mypy only on this class, we risk missing relevant errors (as it recently happened - see the fix in fix: improve component.output_types decorator type hinting to support run_async methods #9102)
  • lint job (which includes mypy) currently takes < 2 minutes, while integration tests running at the same time take around 7 minutes. Even if running mypy on all files adds 30s–1m to the lint job, it would not be a bottleneck for contributors.

@davidsbatista
Copy link
Copy Markdown
Contributor

I understand now in detail the issue here - we still should keep an eye for the time this takes, my concern is that this can become a bootleneck

@anakin87
Copy link
Copy Markdown
Member Author

I understand now in detail the issue here - we still should keep an eye for the time this takes, my concern is that this can become a bootleneck

I will keep an eye on it.

@anakin87 anakin87 merged commit 593ca87 into main Mar 25, 2025
6 checks passed
@anakin87 anakin87 deleted the always-run-mypy branch March 25, 2025 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants