refactor: centralize query files in an IntrospectionQuery enum - #177
Merged
Conversation
Replace the scattered "*.sql" string literals passed to run_introspection_query with an IntrospectionQuery enum: one member per query, each carrying its file name and kind (load vs guard). Callers pass a member; the enum is the single place that maps a query to its file. matview_dependencies.sql backs two members (its loader and its guard). Pure refactor: no behavior change. `kind` is metadata for now. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vc8vdq3jNTBHg3TfV6L7BD
Add the missing EXTENSIONS and DEFAULT_PRIVILEGES match cases (the lookup was non-exhaustive and fell through with no return), and resolve the query's file via get_introspection_query_config instead of a non-existent IntrospectionQuery.file_name attribute. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vc8vdq3jNTBHg3TfV6L7BD
The match already enumerates every IntrospectionQuery member, so the `case _: assert_never(query)` was unreachable (mypy warn_unreachable) and uncovered, and `assert_never` is not importable from typing on 3.10. Exhaustiveness is still enforced by the return type: a new member with no case falls through and trips "Missing return". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vc8vdq3jNTBHg3TfV6L7BD
A match over IntrospectionQuery with no wildcard leaves an implicit "no case matched" branch that never runs, so branch coverage never reaches 100%; adding `case _: assert_never` covers it but trips mypy warn_unreachable and is not importable on 3.10. A dict lookup is a branchless total mapping -- 100% coverage, no unreachable code. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vc8vdq3jNTBHg3TfV6L7BD
…ping_extensions The match statement is the intended idiom here (pytest.ini already excludes `case _: assert_never(` from coverage). The only real bug was importing assert_never from typing, which does not exist there before 3.11 -- on 3.10 that made mypy treat the case body as unreachable. Importing from typing_extensions resolves it on every version; mypy (warn_unreachable) then accepts the exhaustiveness marker and coverage excludes it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vc8vdq3jNTBHg3TfV6L7BD
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.
What
Replace the scattered
"*.sql"string literals passed torun_introspection_querywith anIntrospectionQueryenum. One member per query, each carrying its file name and kind (LOADvsGUARD). Callers pass a member; the enum is the single place that maps a query to its file.matview_dependencies.sqlbacks two members (its loader and its guard).Behavior
Pure refactor: no behavior change.
kindis metadata for now (groundwork for--ignore-schema, which will filter onlyLOADqueries).Notes
The preflight query is tagged
GUARD(runs before loaders, must see every schema).