Skip to content

Add __iter__ to TaxonomyIterator to satisfy Python iterator protocol#79

Merged
audy merged 1 commit intomasterfrom
fix/taxonomy-iterator-protocol
Apr 13, 2026
Merged

Add __iter__ to TaxonomyIterator to satisfy Python iterator protocol#79
audy merged 1 commit intomasterfrom
fix/taxonomy-iterator-protocol

Conversation

@audy
Copy link
Copy Markdown
Contributor

@audy audy commented Apr 10, 2026

Taxonomy doesn't have __iter__. This causes the following to break in IPython/Python REPL. I'm not sure why, but it doesn't fail if you run this in a script.

tax: taxonomy.Taxonomy

[ i for i in tax ] 

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[1], line 1
----> 1 [ i for i in build.taxonomy ]

TypeError: 'builtins.TaxonomyIterator' object is not iterable

The fix was to add __iter__

[🤖] Improve iterator test to actually verify iterator protocol
@audy audy force-pushed the fix/taxonomy-iterator-protocol branch from 1bc2ac3 to 18ed97e Compare April 10, 2026 23:20
@audy audy marked this pull request as ready for review April 10, 2026 23:23
Copy link
Copy Markdown
Contributor

@pkonieczny pkonieczny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@audy audy merged commit d70f8cd into master Apr 13, 2026
21 checks passed
@audy audy deleted the fix/taxonomy-iterator-protocol branch April 13, 2026 14:53
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.

3 participants