Skip to content

boolean evalutation of TableList breaks when its tables are an iterable #655

@Pauarnal

Description

@Pauarnal

TableList is defined as class camelot.core.TableList(tables: Iterable[Table]), however when evaluated as boolean, it uses len(tables), which doesn't work on all iterables, only ones which length is known.

To reproduce, simply evaluate as boolean a TableList built from an iterable of Tables. This usage fits the spec but breaks:

bool(TableList(x for x in old_tablelist))

Either the __bool__ method should change somehow (but with general iterables, there is no way to know beforehand if an iterable has elemnts or not without consuming it), or the typing should be changed to reflect that not only it must be an Iterable, it should also be a Sized object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions