microsoft / microsoft/winml-cli

Fix CodeQL warning: __init__ calls overridden method prepare_pipeline

Open
#239 1 comment 0 reactions 1 assignee View on GitHub

@timenick is already working on this.

Since Jun 7, 2026.

bug P2 quality triaged
Dominant language
Python
Stars
40
Forks
11
Avg merge
1d 8h
Merged PRs (30d)
50

Description

Problem

CodeQL alert #2 flags py/init-calls-subclass in base_evaluator.py:46.

WinMLEvaluator.__init__ calls self.prepare_pipeline(), which is overridden by 4 subclasses:

  • WinMLImageSegmentationEvaluator
  • WinMLObjectDetectionEvaluator
  • WinMLTextClassificationEvaluator
  • WinMLTokenClassificationEvaluator

This means subclass overrides receive a partially initialized instance. Currently safe because subclasses set their own attributes before super().__init__(), but fragile for future changes.

Proposed Fix

Convert data and pipe to lazy properties in the base class. prepare_pipeline / prepare_data are called on first access instead of during __init__, so the object is fully constructed by then.

  • Change is confined to base_evaluator.py
  • Zero subclass modifications needed
  • Transparent to callers (self.pipe / self.data usage unchanged)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.