Skip to content

fix(orm): resolve basedpyright errors in ORM config and connections - #237

Merged
tmgbedu merged 2 commits into
mainfrom
task/pyright-batch-13-masoniteorm
Sep 25, 2026
Merged

tmgbedu merged 2 commits into
mainfrom
task/pyright-batch-13-masoniteorm

Conversation

@tmgbedu

@tmgbedu tmgbedu commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Batch 13 of the basedpyright cleanup (task #1916). Fixes the errors in masoniteorm/config/, masoniteorm/connections/ and masoniteorm/testing/transaction.py. It doesn't touch the Morph relationships, models/registry.py, schema/Blueprint.py or any file in the open PRs (#170, #196, #220, #222, #235).

basedpyright: 195 → 178 errors, no new errors.

Changes

  • config/config.py: DB_URL, DB_PASSWORD and DB_SOCKET are now read with cast=False, so they stay str.
  • config/database.py: connections is typed as the config dataclasses or a dict, and migrations as dict[str, str]. These are annotation-only changes.
  • connections/connection.py: get_query_grammar and get_post_processor are now typed @classmethods, matching the driver overrides. They still return None.
  • connections/{sqlite,mysql,postgres}_connection.py: added return annotations.
  • connections/factory.py, testing/transaction.py: cast("Application", app()) before calling methods that only exist on Application. str() the migrations path, which Migrator already stringifies internally.

Behavior changes

  • Connection.select() now returns a list of plain dicts instead of SQLAlchemy RowMappings, which matches its declared list[dict] and select_one(). A regression test is included.
  • Env values like DB_PASSWORD=1234 are no longer auto-cast to int in the pydantic config dataclasses. Before, an all-digit password was cast to int, which the str field doesn't accept.

Testing

  • uv run basedpyright: 195 → 178, zero new diagnostics
  • uv run pytest --ignore=tests/masoniteorm/postgres: 2396 passed, 7 skipped
  • ruff check / ruff format --check: clean

- Read DB_URL, DB_PASSWORD and DB_SOCKET without type casting so they stay strings
- Type DatabaseConfig.connections/migrations to match their actual values
- Make base Connection grammar/processor hooks typed classmethods matching the drivers
- Return plain dicts from Connection.select() to match its declared list[dict]
- Cast app() to Application where Application-only methods are used
@codecov

codecov Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@tmgbedu
tmgbedu merged commit f1c42d8 into main Sep 25, 2026
4 of 6 checks passed
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