Skip to content

chore(mypy): add mypy type hints to distributions and testing modules#5404

Open
Elbehery wants to merge 1 commit intollamastack:mainfrom
Elbehery:20260401_add_type_hints_providers_dist
Open

chore(mypy): add mypy type hints to distributions and testing modules#5404
Elbehery wants to merge 1 commit intollamastack:mainfrom
Elbehery:20260401_add_type_hints_providers_dist

Conversation

@Elbehery
Copy link
Copy Markdown
Contributor

@Elbehery Elbehery commented Apr 1, 2026

What does this PR do?

Add type hints to make the following files pass strict mypy checking:

  • src/llama_stack/distributions/template.py: Add explicit type annotations to filtered_dict and filtered_list variables, rename config_class to config_cls to avoid shadowing, rename template variable to jinja_template to avoid shadowing, cast jinja2 render return value to str, add cast to typing imports
  • src/llama_stack/testing/api_recorder.py: Add string annotation for ResponseStorage forward reference, add type annotation for headers dict, add assertion for non-None storage, add type: ignore[method-assign] comments for all method monkey-patching operations

cc @leseb

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 1, 2026
@Elbehery Elbehery force-pushed the 20260401_add_type_hints_providers_dist branch 4 times, most recently from 28f3d5a to 3e1ddf4 Compare April 1, 2026 14:31
@Elbehery Elbehery changed the title chore(mypy): remove distributions and other files from mypy exclude list chore(mypy): add mypy type hints to distributions and testing modules Apr 1, 2026
@Elbehery Elbehery force-pushed the 20260401_add_type_hints_providers_dist branch 3 times, most recently from 3421c11 to b11eabe Compare April 1, 2026 21:00
Copy link
Copy Markdown
Collaborator

@leseb leseb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not rename variables if not necessary

@Elbehery Elbehery force-pushed the 20260401_add_type_hints_providers_dist branch from b11eabe to fc58a62 Compare April 2, 2026 15:08
@Elbehery
Copy link
Copy Markdown
Contributor Author

Elbehery commented Apr 2, 2026

let's not rename variables if not necessary

fixed 👍🏽

Add type hints to make the following files pass strict mypy checking:
- src/llama_stack/distributions/template.py: Add explicit type
  annotations to filtered dict and list variables, cast jinja2 render
  return value to str, add cast to typing imports
- src/llama_stack/testing/api_recorder.py: Add string annotation for
  ResponseStorage forward reference, add type annotation for headers
  dict, add assertion for non-None storage, add
  type: ignore[method-assign] comments for all method monkey-patching
  operations

Signed-off-by: Mustafa Elbehery <melbeher@redhat.com>
@Elbehery Elbehery force-pushed the 20260401_add_type_hints_providers_dist branch from fc58a62 to 0014d95 Compare April 2, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants