Skip to content

fix: Cte.schema return type and use safezip #22

@dtsong

Description

@dtsong

Context

Follow-up from PR #21 code review. Two minor cleanups in Cte.schema.

1. Return type annotation mismatch

Cte.schema is declared -> Schema but the base ITable.schema returns Schema | None. The implementation can return None (when not self.params and source schema is None). Should match the base class signature:

@property
def schema(self) -> Schema | None:

File: data_diff/queries/ast_classes.py, line 637

2. Use safezip instead of manual len check + zip

data_diff/utils.py already provides safezip which enforces equal-length zipping (used in 20+ callsites). The manual len check + zip in Cte.schema could be replaced:

from data_diff.utils import safezip
# ...
result = type(s)(dict(safezip(self.params, s.values())))

This eliminates the separate length-mismatch guard.

File: data_diff/queries/ast_classes.py, lines 643-646

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions