Skip to content

QA: Migrate type checker from mypy to ty#725

Merged
amotl merged 2 commits intomainfrom
mypy-to-ty
Mar 26, 2026
Merged

QA: Migrate type checker from mypy to ty#725
amotl merged 2 commits intomainfrom
mypy-to-ty

Conversation

@amotl
Copy link
Copy Markdown
Member

@amotl amotl commented Mar 25, 2026

ty is a modern Python type checker written in Rust.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 25, 2026

Warning

Rate limit exceeded

@amotl has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 26 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8e7364ea-aa05-4fa1-a1d6-910047811905

📥 Commits

Reviewing files that changed from the base of the PR and between a6f2296 and d3be2ba.

📒 Files selected for processing (77)
  • cratedb_toolkit/__init__.py
  • cratedb_toolkit/adapter/pymongo/api.py
  • cratedb_toolkit/adapter/pymongo/collection.py
  • cratedb_toolkit/adapter/pymongo/cursor.py
  • cratedb_toolkit/adapter/pymongo/reactor.py
  • cratedb_toolkit/adapter/pymongo/util.py
  • cratedb_toolkit/adapter/rockset/cli.py
  • cratedb_toolkit/adapter/rockset/server/api/query.py
  • cratedb_toolkit/cfr/cli.py
  • cratedb_toolkit/cfr/marimo.py
  • cratedb_toolkit/cfr/systable.py
  • cratedb_toolkit/cli.py
  • cratedb_toolkit/cluster/cli.py
  • cratedb_toolkit/cluster/core.py
  • cratedb_toolkit/cluster/croud.py
  • cratedb_toolkit/cmd/tail/main.py
  • cratedb_toolkit/datasets/model.py
  • cratedb_toolkit/datasets/util.py
  • cratedb_toolkit/dms/cli.py
  • cratedb_toolkit/dms/table_mapping.py
  • cratedb_toolkit/docs/functions.py
  • cratedb_toolkit/exception.py
  • cratedb_toolkit/info/http.py
  • cratedb_toolkit/io/awslambda/kinesis.py
  • cratedb_toolkit/io/cratedb/bulk.py
  • cratedb_toolkit/io/kinesis/adapter.py
  • cratedb_toolkit/io/kinesis/relay.py
  • cratedb_toolkit/io/mongodb/adapter.py
  • cratedb_toolkit/io/mongodb/cdc.py
  • cratedb_toolkit/io/mongodb/copy.py
  • cratedb_toolkit/io/mongodb/core.py
  • cratedb_toolkit/io/mongodb/export.py
  • cratedb_toolkit/io/mongodb/transform.py
  • cratedb_toolkit/io/mongodb/translate.py
  • cratedb_toolkit/model.py
  • cratedb_toolkit/query/cli.py
  • cratedb_toolkit/query/mcp/cli.py
  • cratedb_toolkit/query/mcp/pg_mcp.py
  • cratedb_toolkit/retention/cli.py
  • cratedb_toolkit/retention/store.py
  • cratedb_toolkit/testing/testcontainers/azurite.py
  • cratedb_toolkit/testing/testcontainers/cratedb.py
  • cratedb_toolkit/testing/testcontainers/influxdb2.py
  • cratedb_toolkit/testing/testcontainers/localstack.py
  • cratedb_toolkit/testing/testcontainers/mongodb.py
  • cratedb_toolkit/testing/testcontainers/util.py
  • cratedb_toolkit/util/app.py
  • cratedb_toolkit/util/cli.py
  • cratedb_toolkit/util/client.py
  • cratedb_toolkit/util/crash.py
  • cratedb_toolkit/util/croud.py
  • cratedb_toolkit/util/database.py
  • cratedb_toolkit/util/pandas.py
  • cratedb_toolkit/util/platform.py
  • cratedb_toolkit/util/runtime.py
  • cratedb_toolkit/util/setting.py
  • cratedb_toolkit/util/sqlalchemy.py
  • pyproject.toml
  • tests/adapter/test_pymongo.py
  • tests/cfr/test_systable.py
  • tests/cluster/test_core.py
  • tests/conftest.py
  • tests/datasets/test_loading.py
  • tests/examples/test_python.py
  • tests/examples/test_shell.py
  • tests/io/dynamodb/conftest.py
  • tests/io/dynamodb/test_adapter.py
  • tests/io/dynamodb/test_relay.py
  • tests/io/influxdb/conftest.py
  • tests/io/kinesis/conftest.py
  • tests/io/kinesis/manager.py
  • tests/io/kinesis/test_relay.py
  • tests/io/mongodb/conftest.py
  • tests/io/mongodb/test_integration.py
  • tests/io/test_iceberg.py
  • tests/shell/test_cli.py
  • tests/util/test_run_sql.py

Walkthrough

Widespread static-typing and mypy→ty toolchain changes: many parameters annotated as Optional, type-ignore directives adjusted, added small runtime guards/asserts, introduced a new abstract MongoDB adapter method, added Kinesis file-adapter methods, and made bulk and container startup checks. Runtime behavior largely unchanged.

Changes

Cohort / File(s) Summary
Tooling
pyproject.toml
Replace mypy with ty config and dev-task update to ty check.
Global Optional/typing updates
cratedb_toolkit/.../model.py, .../exception.py, .../database.py, .../setting.py, .../runtime.py, .../util.py, .../crash.py, .../croud.py, cratedb_toolkit/io/mongodb/translate.py, cratedb_toolkit/datasets/util.py, cratedb_toolkit/cluster/core.py
Many signatures changed to use Optional[...] / tightened typing to reflect None defaults; no runtime logic changes.
PyMongo adapter & collection
cratedb_toolkit/adapter/pymongo/api.py, .../collection.py, .../cursor.py, .../util.py, .../reactor.py
Removed/adjusted mypy ignores; AmendedCollection.insert_one/insert_many now accept bypass_document_validation: Optional[bool]; added targeted # ty: ignore[...] sites and SQLAlchemy Mapper/registry typing updates.
MongoDB surface & export/transform
cratedb_toolkit/io/mongodb/adapter.py, .../cdc.py, .../copy.py, .../core.py, .../export.py, .../transform.py
Added abstract create_collection to MongoDBAdapterBase; cast collection-name to str at callsites; collection_to_json and convert adjusted to accept/normalize optional params; guards added around schema-dependent logic.
Kinesis & relay
cratedb_toolkit/io/kinesis/adapter.py, .../relay.py, cratedb_toolkit/cmd/tail/main.py
KinesisFileAdapter gains wait_until_ready (returns True) and produce (raises NotImplementedError); producer call typed-ignores added; relay imports SQLAlchemy exceptions directly and adds asserts/casts around translator/DDL; color escape import adjusted.
CrateDB bulk & Rockset API
cratedb_toolkit/io/cratedb/bulk.py, cratedb_toolkit/adapter/rockset/server/api/query.py
BulkResponse fields default to None; BulkProcessor.start() validates batch_to_operation; per-record execute annotated with type-ignore; execute now passes parameters or {} to adapter.run_sql.
Click CLI decorators
multiple cratedb_toolkit/.../cli.py (e.g., cli.py, cluster/cli.py, cfr/cli.py, dms/cli.py, query/..., retention/cli.py, util/app.py)
Removed many # type: ignore[arg-type] comments from @click.group(...) decorators; decorator behavior unchanged.
Testcontainers & container guards
cratedb_toolkit/testing/testcontainers/*, tests/*
Added _wait_strategy presence checks (raise ValueError) in several container _connect() implementations; tightened fixture attribute typings; KeepaliveContainer.stop signature changed; many tests switched raise pytest.skippytest.skip and added inline type-ignore comments.
Pandas / SQLAlchemy / utils / docs
cratedb_toolkit/util/pandas.py, .../sqlalchemy.py, .../client.py, cratedb_toolkit/docs/functions.py
Minor type-ignore adjustments, explicit assert that DataFrame frame is not None, JWT monkey-patch applied only when token present via ExitStack, and sphinx_ref_role now raises if inliner is None.
Tests & small fixes
tests/... (many test modules)
Tightened test imports (direct exception imports, importlib.metadata), added deterministic assertions, adjusted skip semantics and inline # ty: ignore[...] annotations in tests.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • hammerhead
  • surister

Poem

"I’m a rabbit who tidies types tonight,
I nibble ignores and make optionals right,
I add small guards and hop away light,
A patch of asserts, a curious sight,
Hop — clean types, hop — goodnight!"

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 51.11% 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
Title check ✅ Passed The title clearly describes the main change: migrating the type checker from mypy to ty, which aligns with the substantial pyproject.toml changes and widespread removal/replacement of mypy suppression comments throughout the codebase.
Description check ✅ Passed The description is directly related to the changeset, accurately identifying ty as a modern Python type checker written in Rust and explaining the migration purpose.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mypy-to-ty

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@amotl amotl marked this pull request as ready for review March 25, 2026 05:12
coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@amotl amotl merged commit 434b8f3 into main Mar 26, 2026
25 checks passed
@amotl amotl deleted the mypy-to-ty branch March 26, 2026 16:54
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