Repository navigation
fix(core): materialise TableList iterable so bool/len work - #710
Merged
Merged
Conversation
…erable TableList.__init__ accepts Iterable[Table] per its type annotation but stored it as-is, so __len__ (and therefore __bool__) only worked for Sized inputs. Constructing TableList from a generator and then evaluating it as bool — exactly the documented usage — raised TypeError: object of type 'generator' has no len(). Materialise the iterable to a list once in __init__. Adds a regression test that covers an empty and a non-empty generator input. Closes camelot-dev#655.
bosd
force-pushed
the
fix/655-tablelist-iterable
branch
from
May 19, 2026 23:21
e1c1afa to
0de5c09
Compare
bosd
added a commit
that referenced
this pull request
May 20, 2026
The test_tablelist_accepts_iterable from #710 used plain object() as TableList input, which broke the typeguard CI session once #715 landed the `__getitem__(...) -> Table` annotation: typeguard.TypeCheckError: the return value (object) is not an instance of camelot.core.Table Replace the sentinels with MagicMock(spec=Table). isinstance() passes on those (via the spec), the identity assertions (`is`) still work, and typeguard is satisfied. The test still exercises the original bug (__bool__/__len__ on a generator-built TableList).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #655.
TableList.__init__acceptsIterable[Table]per its type annotation but stored the value unchanged.__len__(and therefore__bool__) only worked forSizedcontainers, so the documented usage:raised
TypeError: object of type 'generator' has no len().Materialise the iterable once in
__init__(i.e.list(tables)). Adds a regression test covering empty and non-empty generators.