arturtamborski / notion-py

(Fork of) Unofficial Python API client for Notion.so
https://pypi.org/project/notion-py/
MIT License
63 stars 9 forks source link

CollectionRowBlock.get_all_properties() throws TypeError: 'NoneType' object is not iterable #39

Closed Nocommas555 closed 4 years ago

Nocommas555 commented 4 years ago

I moved from a different fork of notion-py and some code broke

I looked around a bit, and found that the problem is deeper - in /notion/collection.py, convert_notion_to_python, 465: for i, part in enumerate(val):

Therefore, this val == None

The function got this Val from from get_property, line 404 val = self.get(["properties", prop["id"]])

The .get is from the Record class, but i don't know what goes wrong there

Edit: translated into english

arturtamborski commented 4 years ago

That's interesting, it looks as if the prop didn't have a block ID? Thanks for the report (and sorry for a late reply), I'll look at it.

todaysday commented 4 years ago

Hi @arturtamborski Did you have a chance to fix the issue in #41 merge? Looks like I have same problem. I would like to switch to you fork and this is the only blocker for me.

arturtamborski commented 4 years ago

I'll have it on my list but first I have to fix the collections in general.

divinites commented 4 years ago

The same thing, I tracked the error exactly as what was done by @Nocommas555

arturtamborski commented 4 years ago

this is now fixed in release 0.0.5.

import os
from notion.client import NotionClient

client = NotionClient(os.environ["NOTION_TOKEN_V2"])
page = client.get_block(os.environ["NOTION_PAGE_URL"])

cvb = page.children[1]
crb = cvb.collection.get_rows()[0]
print(crb.get_all_properties())
{'qqq': ['qeqwe'], 'asd': 'asdad'}

image

(tagging @divinites, @todaysday, @Nocommas555 for notifications)