Skip to content

refactor: consolidate media constraints via generic base classes#176

Merged
Kamilbenkirane merged 1 commit into
mainfrom
refactor/consolidate-media-constraints
Feb 23, 2026
Merged

refactor: consolidate media constraints via generic base classes#176
Kamilbenkirane merged 1 commit into
mainfrom
refactor/consolidate-media-constraints

Conversation

@Kamilbenkirane

Copy link
Copy Markdown
Member

Summary

  • Replace 6 near-identical media constraint classes (~190 lines of copy-paste) with two generic bases: _MediaConstraint[M: MimeType] and _MediaListConstraint[M: MimeType]
  • Each subclass is now 3 lines (docstring + ClassVar assignments), parameterized by its MimeType enum
  • Update get_constraint_input_type in io.py to use _artifact_type ClassVar fast path instead of __call__ signature introspection

Test plan

  • pytest tests/unit_tests/test_constraints.py tests/unit_tests/test_io.py -v — 95/95 pass
  • mypy src/celeste/constraints.py src/celeste/io.py — clean
  • ruff check src/celeste/constraints.py src/celeste/io.py — clean
  • All pre-commit hooks pass (lint, format, mypy, bandit, tests)

Closes #175

Replace 6 near-identical media constraint classes with two generic bases
(_MediaConstraint[M] and _MediaListConstraint[M]) that use ClassVar
dispatch for artifact type and MimeType generics for type-safe
supported_mime_types. Update get_constraint_input_type to use
_artifact_type ClassVar fast path instead of __call__ introspection.
@claude

claude Bot commented Feb 23, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@Kamilbenkirane

Copy link
Copy Markdown
Member Author

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

@Kamilbenkirane Kamilbenkirane merged commit 4d39d60 into main Feb 23, 2026
11 checks passed
@Kamilbenkirane Kamilbenkirane mentioned this pull request Feb 24, 2026
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.

refactor: consolidate media constraint classes via generic bases

1 participant