Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayInterator missing __iter__ method #198

Closed
ellisonbg opened this issue Dec 6, 2024 · 3 comments · Fixed by #199
Closed

ArrayInterator missing __iter__ method #198

ellisonbg opened this issue Dec 6, 2024 · 3 comments · Fixed by #199
Labels
bug Something isn't working

Comments

@ellisonbg
Copy link

The ArrayIterator is missing the __iter__ method, causing an exception when called (see below). I ran a simple example and verified that iterators need that method. Not sure how the tests are passing though.

[E 2024-12-05 19:14:27.909 ServerApp] Error saving file: Untitled.ipynb
    TypeError("'ArrayIterator' object is not iterable")
    Traceback (most recent call last):
      File "/Users/brgrange/Notebooks/bug398/.pixi/envs/default/lib/python3.13/site-packages/jupyter_server_ydoc/rooms.py", line 285, in _maybe_save_document
        "content": self._document.source,
                   ^^^^^^^^^^^^^^^^^^^^^
      File "/Users/brgrange/Notebooks/bug398/.pixi/envs/default/lib/python3.13/site-packages/jupyter_ydoc/ybasedoc.py", line 90, in source
        return self.get()
               ~~~~~~~~^^
      File "/Users/brgrange/Notebooks/bug398/.pixi/envs/default/lib/python3.13/site-packages/jupyter_ydoc/ynotebook.py", line 204, in get
        cell = self.get_cell(i)
      File "/Users/brgrange/Notebooks/bug398/.pixi/envs/default/lib/python3.13/site-packages/jupyter_ydoc/ynotebook.py", line 106, in get_cell
        cell = self._ycells[index].to_py()
      File "/Users/brgrange/Notebooks/bug398/.pixi/envs/default/lib/python3.13/site-packages/pycrdt/_map.py", line 111, in to_py
        py[key] = val.to_py()
                  ~~~~~~~~~^^
      File "/Users/brgrange/Notebooks/bug398/.pixi/envs/default/lib/python3.13/site-packages/pycrdt/_array.py", line 350, in to_py
        py = [value for value in self]
                                 ^^^^
    TypeError: 'ArrayIterator' object is not iterable
@davidbrochart
Copy link
Collaborator

It's the Array that must have an __iter__() method, and it does:

def __iter__(self) -> ArrayIterator:

@ellisonbg
Copy link
Author

ellisonbg commented Dec 6, 2024 via email

@davidbrochart
Copy link
Collaborator

Thanks, I opened #199.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants