Skip to content

chore: Enable mypy support #82

Merged
arekay-nv merged 12 commits intomainfrom
arekay/add_mypy_support
Feb 2, 2026
Merged

chore: Enable mypy support #82
arekay-nv merged 12 commits intomainfrom
arekay/add_mypy_support

Conversation

@arekay-nv
Copy link
Copy Markdown
Collaborator

@arekay-nv arekay-nv commented Jan 5, 2026

Fixes and enables mypy support for better type checking.

Type of change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor/cleanup

Related issues

Testing

  • Tests added/updated
  • All tests pass locally
  • Manual testing completed

Checklist

  • Code follows project style
  • Pre-commit hooks pass
  • Documentation updated (if needed)

Copilot AI review requested due to automatic review settings January 5, 2026 05:10
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 5, 2026

MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅

@github-actions github-actions bot requested a review from nvzhihanj January 5, 2026 05:10
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @arekay-nv, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on a significant refactor and cleanup effort by integrating mypy for static type checking across the project. The primary goal is to improve the overall robustness and maintainability of the codebase by ensuring type consistency. This involved adding mypy to the development workflow and making targeted adjustments to type annotations and code logic to satisfy the type checker, ultimately leading to a more reliable and easier-to-understand system.

Highlights

  • Mypy Integration: The pull request introduces mypy for static type checking, adding it to the pre-commit configuration and setting up its basic configuration in pyproject.toml to enhance code quality and catch type errors early.
  • Extensive Type Annotations and Refinements: Numerous files across the codebase have received new or updated type annotations to comply with mypy's requirements. This includes explicit type hints for variables, function parameters, return types, and class attributes, significantly improving code clarity and maintainability.
  • Code Adjustments for Type Safety: Several minor code adjustments were made to resolve mypy errors and improve type safety. This includes robust handling of QueryResult response outputs, explicit assertions for potentially None values, refining default values for configuration parameters, and updating type hints for msgspec.Struct classes to suppress mypy warnings.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enables mypy type checking support across the codebase by adding type annotations and fixing existing type-related issues. The changes address mypy errors by adding proper type hints, using Literal types where appropriate, and adding type: ignore comments for known msgspec limitations.

Key changes:

  • Added mypy configuration to pyproject.toml and pre-commit hooks
  • Fixed type annotations throughout the codebase (function signatures, variable declarations, etc.)
  • Added type: ignore comments for msgspec.Struct call-arg issues

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
.pre-commit-config.yaml Added mypy pre-commit hook for automated type checking
pyproject.toml Added mypy configuration with ignore_missing_imports setting
src/inference_endpoint/utils/logging.py Added Literal type for style parameter validation
src/inference_endpoint/utils/dataset_utils.py Added type annotation for token_leng_counts dictionary
src/inference_endpoint/utils/init.py Changed division to floor division for integer type consistency
src/inference_endpoint/sglang/types.py Added type: ignore comments for msgspec.Struct call-arg warnings
src/inference_endpoint/openai/types.py Added type: ignore comments for msgspec.Struct call-arg warnings
src/inference_endpoint/metrics/reporter.py Changed .sum() to sum() for better type inference
src/inference_endpoint/metrics/recorder.py Fixed type annotations for Path and string handling
src/inference_endpoint/metrics/metric.py Added type hints for optional parameters and assertions
src/inference_endpoint/load_generator/session.py Added type annotations for thread and sample_uuid_map
src/inference_endpoint/load_generator/scheduler.py Fixed random.Random default parameter instantiation
src/inference_endpoint/load_generator/sample.py Improved type hint for hook callback parameter
src/inference_endpoint/load_generator/load_generator.py Updated return type and docstring for next method
src/inference_endpoint/endpoint_client/zmq_utils.py Added UnionType support and fixed zmq error handling
src/inference_endpoint/endpoint_client/worker.py Added comprehensive type annotations and assertions throughout worker code
src/inference_endpoint/endpoint_client/http_sample_issuer.py Added assertion for loop existence
src/inference_endpoint/endpoint_client/http_client.py Added type annotations and assertions for event loop handling
src/inference_endpoint/dataset_manager/factory.py Fixed dataset format type handling with assertions
src/inference_endpoint/dataset_manager/dataset.py Changed return type from instance to type class
src/inference_endpoint/core/types.py Added type: ignore comments and new helper method for response output
src/inference_endpoint/config/schema.py Fixed type annotations for parser and timeout fields
src/inference_endpoint/config/rulesets/mlcommons/rules.py Added proper type hints for optional fields and metric handling
src/inference_endpoint/commands/probe.py Refactored response_output handling to use new helper method
src/inference_endpoint/commands/benchmark.py Added type annotations and improved type safety with assertions
Comments suppressed due to low confidence (1)

src/inference_endpoint/config/rulesets/mlcommons/rules.py:1

  • The expression d.parser or None is redundant - if d.parser is falsy, it's already None. Simply use [d.parser for d in config.datasets] instead.
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request does a great job of enabling mypy and fixing a large number of typing-related issues throughout the codebase. The changes significantly improve type safety and code clarity. I've identified a couple of areas where the implementation can be further improved for correctness and to reduce code duplication. Overall, this is a solid step towards a more robust and maintainable codebase.

Copilot AI review requested due to automatic review settings January 5, 2026 15:49
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 29 out of 29 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings January 5, 2026 16:31
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings January 5, 2026 18:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 9 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Added mypy configuration to pyproject.toml
- Enabled pre-commit hooks for type checking
- Added type annotations across endpoint_client, commands, and load_generator modules
- Fixed type-related issues throughout the codebase
- Configured mypy to run as warning in pre-commit

This change improves code quality and catches type errors during development.
Copilot AI review requested due to automatic review settings January 30, 2026 03:52
@arekay-nv arekay-nv force-pushed the arekay/add_mypy_support branch from 5da98f4 to ea5495c Compare January 30, 2026 03:52
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 29 out of 29 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Rashid Kaleem <230885705+arekay-nv@users.noreply.github.com>
Signed-off-by: Rashid Kaleem <230885705+arekay-nv@users.noreply.github.com>
Copilot AI review requested due to automatic review settings January 30, 2026 15:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 32 out of 32 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Rashid Kaleem <230885705+arekay-nv@users.noreply.github.com>
@arekay-nv arekay-nv marked this pull request as ready for review January 30, 2026 23:05
@arekay-nv arekay-nv requested a review from a team as a code owner January 30, 2026 23:05
Copilot AI review requested due to automatic review settings January 30, 2026 23:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 43 out of 43 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Rashid Kaleem <230885705+arekay-nv@users.noreply.github.com>
@arekay-nv arekay-nv requested a review from Copilot January 31, 2026 00:02
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 43 out of 43 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Rashid Kaleem <230885705+arekay-nv@users.noreply.github.com>
Signed-off-by: Rashid Kaleem <230885705+arekay-nv@users.noreply.github.com>
Copilot AI review requested due to automatic review settings January 31, 2026 06:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 43 out of 43 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Rashid Kaleem <230885705+arekay-nv@users.noreply.github.com>
Signed-off-by: Rashid Kaleem <230885705+arekay-nv@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 2, 2026 18:59
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 44 out of 44 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Rashid Kaleem <230885705+arekay-nv@users.noreply.github.com>
Signed-off-by: Rashid Kaleem <230885705+arekay-nv@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 2, 2026 19:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 44 out of 44 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Rashid Kaleem <230885705+arekay-nv@users.noreply.github.com>
@arekay-nv arekay-nv merged commit 17abd7d into main Feb 2, 2026
3 of 10 checks passed
@arekay-nv arekay-nv deleted the arekay/add_mypy_support branch February 2, 2026 23:28
@github-actions github-actions bot locked and limited conversation to collaborators Feb 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants