Skip to content

Align Parser return-type hints with actual UniqueList returns#632

Open
collerek wants to merge 1 commit into
masterfrom
fix/issue-291-uniquelist-type-hints
Open

Align Parser return-type hints with actual UniqueList returns#632
collerek wants to merge 1 commit into
masterfrom
fix/issue-291-uniquelist-type-hints

Conversation

@collerek
Copy link
Copy Markdown
Collaborator

Summary

  • Several Parser properties (columns, tables, with_names, subqueries_names, columns_aliases_names) were annotated as list[str] but actually return UniqueList, which silently deduplicates on append. Callers writing tests against list semantics could be surprised by the dedup behavior.
  • Updated the public property annotations and propagated the change to the extractor signatures (TableExtractor.extract, NestedResolver.extract_cte_names, NestedResolver.extract_subqueries) so the contract is end-to-end honest about what the code has always done.
  • No behavior change — the underlying objects were already UniqueList; only the annotations and :rtype: docstrings were misleading.

Resolves #291.

Test plan

  • poetry run pytest -vv --cov=sql_metadata --cov-report=term-missing — 271 passed, 100% coverage
  • poetry run mypy sql_metadata — clean
  • poetry run ruff check sql_metadata — clean

🤖 Generated with Claude Code

Properties like `columns`, `tables`, `with_names`, `subqueries_names`,
and `columns_aliases_names` were annotated as `list[str]` but actually
returned `UniqueList`, which silently deduplicates on append. The
mismatch surprised callers who wrote tests against `list` semantics and
got dedup behavior at runtime.

Updates the annotations (and matching extractor signatures in
`TableExtractor.extract`, `NestedResolver.extract_cte_names`,
`NestedResolver.extract_subqueries`) to declare `UniqueList`, so the
public contract reflects what the code has always done.

Resolves #291.

Co-Authored-By: Claude <noreply@anthropic.com>
@collerek collerek requested a review from macbre as a code owner May 14, 2026 09:47
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.

return type of UniqueList inconsistent with type hint of List

1 participant