microsoft / microsoft/winml-cli
Fix CodeQL warning: __init__ calls overridden method prepare_pipeline
@timenick is already working on this.
Since Jun 7, 2026.
- 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:
WinMLImageSegmentationEvaluatorWinMLObjectDetectionEvaluatorWinMLTextClassificationEvaluatorWinMLTokenClassificationEvaluator
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.datausage unchanged)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.