Skip to content

chore(deps): upgrade ruff and ty with strict checking - #1167

Merged
phernandez merged 2 commits into
mainfrom
codex/upgrade-ruff-ty
Jul 27, 2026
Merged

chore(deps): upgrade ruff and ty with strict checking#1167
phernandez merged 2 commits into
mainfrom
codex/upgrade-ruff-ty

Conversation

@phernandez

Copy link
Copy Markdown
Member

Why

Ruff and ty had fallen behind their current releases, and the repository still carried a
Pyright-specific configuration even though ty is the primary type-checking gate. Moving to ty's
complete current rule set exposed 489 diagnostics that were previously disabled or advisory.

This change upgrades the tools and fixes the codebase so those diagnostics are enforced as errors
across both production code and tests.

What Changed

  • Upgrade Ruff to 0.16.0 and ty to 0.0.64 in pyproject.toml and uv.lock.
  • Remove [tool.pyright]; no Black configuration existed to remove.
  • Configure ty with all = "error" and no warning downgrades.
  • Add explicit generic arguments and 165 @override decorators across src/, tests/, and
    test-int/.
  • Replace bare dictionary annotations with explicit dict[str, Any] mappings where the existing
    code intentionally accepts dynamic values.
  • Fix prompt rendering when related results exist without a primary result, with regression
    coverage.
  • Remove duplicate Windows event-loop policy setup while retaining the Python 3.12-3.15
    compatibility seam in the database bootstrap.

Implementation Details

Ruff 0.16 expands its default lint selection and begins formatting Markdown code fences. This PR
preserves the repository's existing E4, E7, E9, and F lint baseline and excludes Markdown
from formatting so the executable upgrade does not silently introduce a second, unrelated lint
migration.

Ty's all-rules configuration initially produced 489 errors: primarily missing generic arguments
and missing @override decorators. The migration fixes those at their source rather than
suppressing the rules globally. A probe using dict[str, object] caused more than 200 invalid
downstream operations, so existing dynamic mappings are represented honestly as
dict[str, Any].

The remaining type fixes preserve concrete types across importer helpers, SQLAlchemy selects and
sessions, task/result containers, subprocess results, WebDAV writes, and template callbacks.
Strict analysis also exposed an uninitialized relation-resolution path and a related-only MCP
prompt rendering bug.

Python's process-wide event-loop policy API is deprecated for removal in 3.16, but Basic Memory
supports 3.12-3.15 and currently has independently owned CLI and FastMCP/AnyIO loop entrypoints.
The existing policy seam remains behind narrow, documented deprecated ignores. Migrating those
entrypoints to explicit loop factories is intentionally deferred until the supported runtime
contract can change.

Reviewer Guide

The two commits separate the behavioral MCP prompt fix from the broad strict-typing migration.
Most of the 163-file diff is mechanical typing metadata:

  • 82 test and integration-test files
  • 79 source files
  • pyproject.toml and uv.lock

Testing

Automated

  • just fast-check: passed; Ruff check/fix, Ruff format, and strict ty all passed.
  • .venv/bin/ty check src tests test-int --python-platform all --output-format concise: passed.
  • .venv/bin/pytest -q tests/mcp/test_prompts.py: 12 passed.
  • Focused changed-surface suite across prompt, importer, cloud upload, repository, scheduler, and
    asyncio-policy tests: 158 passed.
  • uv lock --check: passed; resolved 200 packages.
  • git diff --check: passed.
  • just fast-test: 4,972 passed and 33 skipped. The only failure was the opt-in
    postgres-openai semantic-quality benchmark, which received 429 insufficient_quota while
    seeding external OpenAI embeddings. The SQLite, Postgres FTS, and FastEmbed variants passed.

Manual

  • Reviewed the full 163-file diff and separated the discovered prompt behavior fix into its own
    commit.

Risks / Follow-ups

  • Enabling all = "error" intentionally means future ty upgrades may require new code changes
    when ty adds or strengthens rules.
  • Replace the asyncio policy compatibility seam with explicit loop factories before Python 3.16
    support.
  • The external OpenAI semantic-quality benchmark needs an account with available quota for a
    fully green live-provider run; no product assertion failed in that test.

Signed-off-by: phernandez <paul@basicmachines.co>
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez
phernandez merged commit cb95e59 into main Jul 27, 2026
25 checks passed
@phernandez
phernandez deleted the codex/upgrade-ruff-ty branch July 27, 2026 22:28
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