Skip to content

refactor: centralize query files in an IntrospectionQuery enum - #177

Merged
Apakottur merged 7 commits into
mainfrom
refactor/introspection-query-enum
Jul 20, 2026
Merged

refactor: centralize query files in an IntrospectionQuery enum#177
Apakottur merged 7 commits into
mainfrom
refactor/introspection-query-enum

Conversation

@Apakottur

Copy link
Copy Markdown
Owner

What

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).

Behavior

Pure refactor: no behavior change. kind is metadata for now (groundwork for --ignore-schema, which will filter only LOAD queries).

Notes

The preflight query is tagged GUARD (runs before loaders, must see every schema).

Apakottur and others added 7 commits July 20, 2026 11:01
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
@Apakottur
Apakottur merged commit 8c8f3a8 into main Jul 20, 2026
16 checks passed
@Apakottur
Apakottur deleted the refactor/introspection-query-enum branch July 20, 2026 11:49
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