Skip to content

chore: annotate ImageCore and fix its docstring placeholders - #254

Merged
petercorke merged 2 commits into
mainfrom
chore/types-image-core
Nov 23, 2026
Merged

petercorke merged 2 commits into
mainfrom
chore/types-image-core

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Annotates ImageCore.py, the largest gap in the type-hint work of Issue 60 (61 of 142 parameters and 7 of 132 returns were unannotated). Annotation and docstring changes only, no behaviour change.

  • All 32 operator methods (__mul__, __add__, __and__, comparisons and so on) take other: ImageOperand, a new alias for what can be the right operand: an Image, an array or a scalar. __mod__ and __imod__ take an Image or a scalar, since they stack planes. _binop, _logicalop and _unop are typed. sameas takes object.
  • __array_ufunc__ and __array_function__, colordict, colororder2dict (which already accepts None), plane, print(file=), rprint, __init__(domain=, **kwargs), __getitem__ and pixels_mask are typed. plane is typed int | str | list[int] | tuple[int, ...] because a list of names raises ValueError.
  • Annotating exposed three variable-reuse problems, fixed without changing what the code does: colordict, colororder2dict and plane reassigned their parameter or loop variable to a different type, so they now use a new name. __mod__ and __imod__ use a cast, because mypy cannot see that smb.isscalar narrows the type. The four ordering comparisons carry a # type: ignore[misc] because ndarray has the reflected comparison.
  • Docstrings: four AUTO_EDIT placeholders are removed, and the Image class has a docstring (the text above it was a bare string, so it was not one). With autoclass_content = "both" it is shown above the __init__ text in the docs.

I left alone what is not part of this change: the 87 :seealso: fields and the 92 Example: blocks, which AGENTS.md says to migrate gradually, and draw_labelbox and draw_text, whose examples are plots, not runblock.

mypy reports no issues and the full suite passes (2145 passed, 33 skipped). Parameter annotations across the package go from 86.8% to 89.9%, and ImageCore.py has none missing.

AI-assisted: written with Claude Code (Claude Sonnet 5.5) and reviewed by the maintainer.

🤖 Generated with Claude Code

Part of Issue 60. Annotates the remaining parameters and returns in
ImageCore.py, adds an ImageOperand alias for the right operand of the
operators, removes four AUTO_EDIT placeholders from docstrings, and gives the
Image class a docstring (the text above it was a bare string).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@petercorke
petercorke merged commit d4fee87 into main Nov 23, 2026
32 checks passed
@petercorke
petercorke deleted the chore/types-image-core branch November 23, 2026 07:31
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.

1 participant