Skip to content

Potential conflicting type checks and dead code in /src/datasets/table.py #7968

@rc4typecheck

Description

@rc4typecheck

When statically analyzing and manually reviewing the code, I noticed a potential logic conflicting in /src/datasets/table.py as follows:

def to_blocks(table: Union[pa.Table, Table]) -> list[list[TableBlock]]:
      if isinstance(table, pa.Table):
          return [[InMemoryTable(table)]]
      elif isinstance(table, ConcatenationTable):  # dead code
          return copy.deepcopy(table.blocks)
      else:
          return [[table]]

Within the function, the condition isinstance(table, ConcatenationTable) at line 4 will never be True because the previous condition isinstance(table, pa.Table) at line 2 would have already caught all instances of ConcatenationTable (since ConcatenationTable is a subtype of pa.Table). This creates a logical conflict in the type checking flow.

Please verify if this logic is intentional or it is an issue warranting a refactoring or fixing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions