Skip to content

fix: correct type annotations and improve CI cache invalidation#579

Merged
ajbozarth merged 1 commit intogenerative-computing:mainfrom
ajbozarth:fix/mypy-type-errors-and-ci-cache
Mar 5, 2026
Merged

fix: correct type annotations and improve CI cache invalidation#579
ajbozarth merged 1 commit intogenerative-computing:mainfrom
ajbozarth:fix/mypy-type-errors-and-ci-cache

Conversation

@ajbozarth
Copy link
Contributor

@ajbozarth ajbozarth commented Mar 5, 2026

Misc PR

Type of PR

  • Bug Fix
  • New Feature
  • Documentation
  • Other

Description

  • Link to Issue:

Fix MyPy Type Errors and CI Cache Invalidation

Problem

MyPy type errors were occurring locally but not caught in CI:

mellea/formatters/granite/retrievers/elasticsearch.py:25: error: Argument 2 to "Elasticsearch" has incompatible type "**dict[str, dict[str, int]]"

Root Cause

  1. Type Error: Incorrect **kwargs annotation (dict[str, int] instead of Any) in elasticsearch.py
  2. CI Cache Issue: Pre-commit cache key didn't include uv.lock, so MyPy used stale cached results when dependencies changed

The bug was introduced when PR #571 (code) and PR #570 (dependencies) were merged separately. CI never re-checked the files with the new type information because the cache wasn't invalidated.

Changes

Type Fix

  • Fixed **kwargs: dict[str, int]**kwargs: Any in elasticsearch.py

CI Fix

  • Updated pre-commit cache key to include uv.lock hash
  • Ensures MyPy re-checks files whenever dependencies change

Testing

pre-commit run --all-files passes locally
✅ All MyPy type checks pass

Impact

Prevents future type errors from being masked by stale CI cache when dependencies are added or updated.

Testing

  • Tests added to the respective file if code was changed
  • New code has 100% coverage if code as added
  • Ensure existing tests and github automation passes (a maintainer will kick off the github automation when the rest of the PR is populated)

@ajbozarth ajbozarth self-assigned this Mar 5, 2026
@ajbozarth ajbozarth requested a review from a team as a code owner March 5, 2026 00:21
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

The PR description has been updated. Please fill out the template for your PR to be reviewed.

@mergify
Copy link

mergify bot commented Mar 5, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|release)(?:\(.+\))?:

psschwei
psschwei previously approved these changes Mar 5, 2026
@psschwei psschwei dismissed their stale review March 5, 2026 00:32

ci failures

- Fix incorrect **kwargs type annotation in elasticsearch.py (dict[str, int] -> Any)
- Remove unnecessary type: ignore comments for imports now in pyproject.toml
- Update CI pre-commit cache key to include uv.lock hash
- Ensures MyPy re-checks files when dependencies change

Fixes type errors introduced in generative-computing#571 that were masked by stale CI cache.

Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
@ajbozarth ajbozarth force-pushed the fix/mypy-type-errors-and-ci-cache branch from cec5261 to 45031b1 Compare March 5, 2026 00:40
@nrfulton
Copy link
Member

nrfulton commented Mar 5, 2026

thanks for the quick investigation.

CI never re-checked the files with the new type information because the cache wasn't invalidated.

Is this a bug in our ci/cd or does this fall into the category of stuff we'd rather handle with nightlies so that the github actions ci/cd has fast-as-possible turn-around?

@ajbozarth
Copy link
Contributor Author

Is this a bug in our ci/cd or does this fall into the category of stuff we'd rather handle with nightlies so that the github actions ci/cd has fast-as-possible turn-around?

I would consider it a bug, but it's up to interpretation. I think the current cache hashing was overzealous and had the potential to hid issues caused by dependency version updates.

Though this fix can end up slowing down the CI it is a drop in the bucket compared to out tests

@nrfulton
Copy link
Member

nrfulton commented Mar 5, 2026

I think some slow-down is fine - mypy breakage is deeply disruptive to all downstream work. IMO the balance of concerns here justified invalidation.

@ajbozarth ajbozarth enabled auto-merge March 5, 2026 01:00
@nrfulton nrfulton self-requested a review March 5, 2026 01:01
@ajbozarth ajbozarth added this pull request to the merge queue Mar 5, 2026
Merged via the queue into generative-computing:main with commit dfc8942 Mar 5, 2026
5 checks passed
@ajbozarth ajbozarth deleted the fix/mypy-type-errors-and-ci-cache branch March 5, 2026 01:19
planetf1 pushed a commit to planetf1/mellea that referenced this pull request Mar 6, 2026
…rative-computing#579)

- Fix incorrect **kwargs type annotation in elasticsearch.py (dict[str, int] -> Any)
- Remove unnecessary type: ignore comments for imports now in pyproject.toml
- Update CI pre-commit cache key to include uv.lock hash
- Ensures MyPy re-checks files when dependencies change

Fixes type errors introduced in generative-computing#571 that were masked by stale CI cache.

Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants