fix(orm): resolve basedpyright errors in ORM config and connections - #237
Merged
Merged
Conversation
- 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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Batch 13 of the basedpyright cleanup (task #1916). Fixes the errors in
masoniteorm/config/,masoniteorm/connections/andmasoniteorm/testing/transaction.py. It doesn't touch the Morph relationships,models/registry.py,schema/Blueprint.pyor 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_PASSWORDandDB_SOCKETare now read withcast=False, so they staystr.config/database.py:connectionsis typed as the config dataclasses or a dict, andmigrationsasdict[str, str]. These are annotation-only changes.connections/connection.py:get_query_grammarandget_post_processorare now typed@classmethods, matching the driver overrides. They still returnNone.connections/{sqlite,mysql,postgres}_connection.py: added return annotations.connections/factory.py,testing/transaction.py:cast("Application", app())before calling methods that only exist onApplication.str()the migrations path, whichMigratoralready stringifies internally.Behavior changes
Connection.select()now returns a list of plaindicts instead of SQLAlchemyRowMappings, which matches its declaredlist[dict]andselect_one(). A regression test is included.DB_PASSWORD=1234are no longer auto-cast tointin the pydantic config dataclasses. Before, an all-digit password was cast toint, which thestrfield doesn't accept.Testing
uv run basedpyright: 195 → 178, zero new diagnosticsuv run pytest --ignore=tests/masoniteorm/postgres: 2396 passed, 7 skippedruff check/ruff format --check: clean