Skip to content

[mypy] Enable mypy for some files in OV and ONNX backends#4099

Open
AlexanderDokuchaev wants to merge 5 commits into
openvinotoolkit:developfrom
AlexanderDokuchaev:ad/mypy_2
Open

[mypy] Enable mypy for some files in OV and ONNX backends#4099
AlexanderDokuchaev wants to merge 5 commits into
openvinotoolkit:developfrom
AlexanderDokuchaev:ad/mypy_2

Conversation

@AlexanderDokuchaev

@AlexanderDokuchaev AlexanderDokuchaev commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Changes

  • Install onnx, onxxruntime and openvino packages in the worflow
  • Enable mypy for 15 files (total 218 files checks)

Reason for changes

Code quality

Related tickets

Tests

@AlexanderDokuchaev AlexanderDokuchaev changed the title Ad/mypy 2 [mypy] Enable mypy for some files in OV and ONNX backends Jun 16, 2026
@AlexanderDokuchaev AlexanderDokuchaev marked this pull request as ready for review June 16, 2026 08:17
@AlexanderDokuchaev AlexanderDokuchaev requested a review from a team as a code owner June 16, 2026 08:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 aims to expand strict mypy coverage for parts of the OpenVINO and ONNX backends by (1) installing the required backend dependencies in the mypy CI workflow and (2) tightening/adding type annotations in several backend modules, while reducing the mypy exclude list.

Changes:

  • Update mypy CI workflow to install onnx, onnxruntime, and openvino so backend imports can be type-checked.
  • Reduce mypy exclude list in pyproject.toml to enable checking of additional OV/ONNX files.
  • Add/adjust type annotations across several OV/ONNX backend modules to satisfy strict mypy.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/nncf/openvino/rt_info.py Tighten parameter/collection type hints for RT info dumping helpers.
src/nncf/openvino/quantization/default_quantization.py Add explicit dict type for trait→metatype mapping.
src/nncf/openvino/quantization/backend_parameters.py Suppress no-any-return for backend-param access (recommend removing ignore via casting).
src/nncf/openvino/graph/transformations/commands.py Improve typing for equality and numpy array parameters in OV transformation commands.
src/nncf/openvino/graph/node_utils.py Refine metatype parameter typing for weighted-layer attribute extraction.
src/nncf/openvino/graph/model_builder.py Add return type for __init__ and annotate deque element type.
src/nncf/openvino/graph/layout.py Fix tuple return types to variadic tuple typing and refine metatype typing.
src/nncf/openvino/engine.py Add typed numpy input/output signatures for OV inference engines.
src/nncf/openvino/cpu_info.py Add no-any-return ignores for OpenVINO property getters (recommend converting to str).
src/nncf/onnx/graph/transformations/commands.py Add typing import and refine numpy array typing; adjust __eq__ signature.
src/nncf/onnx/graph/transformations/command_creation.py Refine numpy array typing in command creation helpers.
src/nncf/onnx/graph/onnx_helper.py Refine return/variable typing for edge/tensor helpers and packing utilities.
src/nncf/onnx/graph/model_transformer.py Make transformer generic over onnx.ModelProto and refine initializer typing.
src/nncf/onnx/engine.py Refine ONNX engine I/O typing for inference.
src/nncf/common/utils/backend.py Remove mypy ignore from onnx import now that CI installs it.
src/nncf/common/factory.py Remove mypy ignore from onnx import used for backend dispatch.
pyproject.toml Reduce mypy exclude list to enable checking of additional backend files.
.github/workflows/mypy.yml Install backend deps (onnx, onnxruntime, openvino) in mypy workflow.

Comment thread src/nncf/openvino/engine.py Outdated
Comment thread src/nncf/openvino/engine.py Outdated
Comment thread src/nncf/openvino/quantization/backend_parameters.py
Comment thread src/nncf/openvino/cpu_info.py
Comment thread src/nncf/openvino/cpu_info.py
Comment thread src/nncf/onnx/graph/transformations/commands.py Outdated
Comment thread src/nncf/openvino/graph/layout.py
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.

2 participants