Skip to content

Conversation

@amureki
Copy link
Member

@amureki amureki commented Jan 22, 2026

Describe the change
Replace mypy with ty as the primary type checker with stricter type checks.

PR Checklist

  • Change is covered with tests
  • CHANGELOG.md is updated if needed

Summary by CodeRabbit

  • Chores
    • Migrated the project type-checker from mypy to ty and updated dev dependencies.
    • Updated CI, build/lint targets, and project configuration to use the new tool.
    • Added typing suppressions and minor internal typing adjustments to reduce false-positive type warnings for optional integrations.

✏️ Tip: You can customize this high-level summary in your review settings.

@amureki amureki self-assigned this Jan 22, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 2026

📝 Walkthrough

Walkthrough

This PR migrates the project from mypy to ty as the primary type checker, updating CI, Makefile, and pyproject config, and adds inline ty/misc type-ignore annotations across several modules while refactoring recipe loading to avoid casts and adjust return typing.

Changes

Cohort / File(s) Summary
Build & Configuration
.github/workflows/ci.yml, Makefile, pyproject.toml, CHANGELOG.md
Replace mypy with ty in CI, Makefile lint target, and dev dependencies; replace [tool.mypy] with [tool.ty.rules] and add new ty rule keys; document change in CHANGELOG.
Module fallback typing
model_bakery/generators.py
Added # type: ignore[misc,assignment] to several optional PostgreSQL-related module-level fallbacks (ArrayField, HStoreField, CICharField, CIEmailField, CITextField, BigIntegerRangeField, DateRangeField, DateTimeRangeField, DecimalRangeField, IntegerRangeField).
Dynamic import typing
model_bakery/random_gen.py
Added # ty: ignore[unresolved-import] annotations to psycopg/psycopg2 dynamic import blocks used by range generator functions; no runtime behavior changes.
Typing silence in baker
model_bakery/baker.py
Added # ty: ignore[no-matching-overload] to a through-model creation call in _handle_m2m to silence overload typing errors; behavior unchanged.
Recipe loader refactor
model_bakery/recipe.py
_load_recipe_from_calling_module renamed parameter to recipe_name: str and returns Recipe[Any]; removed casts and Model import; foreign_key updated to use a resolved_recipe variable and return RecipeForeignKey(resolved_recipe, ...).

Sequence Diagram(s)

(Skipped — changes are typing/tooling/configuration and small internal refactors without new multi-component control flow.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 From mypy's meadow to ty's bright glen,

I hop with comments that silence when,
Recipes cleansed of casts and fear,
Imports annotated, warnings clear,
A tiny rabbit cheers the type frontier.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: replacing mypy with ty as the type checker for development purposes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@amureki amureki merged commit bc907af into main Jan 22, 2026
45 checks passed
@amureki amureki deleted the ty branch January 22, 2026 12:14
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.

2 participants