Skip to content

chore: annotate ImageConstants - #258

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

petercorke merged 2 commits into
mainfrom
chore/types-constants

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Annotates ImageConstants.py, the next file in the type-hint work of Issue 60 (10 of 70 parameters and 4 of 14 returns were unannotated). Annotation and docstring changes only, no behaviour change.

  • The like argument of the nine pattern constructors (Zeros, Constant, Random, Squares, Circles, Ramp, Sin, Chequerboard, Polygons) is Image | None. Image is imported under TYPE_CHECKING, since ImageCore imports this module.
  • _getshape returns list[int], _resolve_pattern_options returns tuple[Any, Any, str | None], _pattern_image returns Any, and str2array inside Image.Constant is str -> list[list[int]]. The cls argument of the helpers is left untyped, because type[Image] does not match the mixin's type[Self]. _getshape uses a cast for [h, w], since mypy cannot see through the Sequence option that both are ints by then.
  • The mixin class has a docstring.

I left alone the 5 :seealso: fields and 10 Example: blocks, which AGENTS.md says to migrate gradually.

mypy reports no issues and the full suite passes (2158 passed, 33 skipped).

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

🤖 Generated with Claude Code

Part of Issue 60. Types the like argument of the pattern constructors as
Image | None, and the helpers _getshape, _resolve_pattern_options and
_pattern_image and the str2array function inside Image.Constant. Gives the
mixin a docstring.

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 d1c51dd into main Nov 23, 2026
32 checks passed
@petercorke
petercorke deleted the chore/types-constants branch November 23, 2026 08:57
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