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

fix(client): fix NoneType not subscriptable error in listMaskUrls #1118

Merged
merged 1 commit into from
Nov 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions tensorbay/client/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,9 @@ def _generate_data(self, offset: int = 0, limit: int = 128) -> Generator[RemoteD
for key in _MASK_KEYS:
mask = getattr(label, key, None)
if mask:
mask.url = URL.from_getter(mask_urls[key].items[i].get, mask_urls[key].pull)
mask.url = URL.from_getter(
mask_urls[key].items[i].get, mask_urls[key].pull # type: ignore[arg-type]
)
mask.cache_path = os.path.join(self._cache_path, key, mask.path)

yield data
Expand All @@ -444,11 +446,11 @@ def _generate_urls(self, offset: int = 0, limit: int = 128) -> Generator[str, No

def _generate_mask_urls(
self, mask_type: str, offset: int = 0, limit: int = 128
) -> Generator[str, None, int]:
) -> Generator[Optional[str], None, int]:
response = self._list_mask_urls(mask_type, offset, limit)

for item in response["urls"]:
yield item["url"]
yield item["url"] if item else None

return response["totalCount"] # type: ignore[no-any-return]

Expand Down Expand Up @@ -772,7 +774,7 @@ def list_urls(self) -> PagingList[str]:
"""
return PagingList(self._generate_urls, 128)

def list_mask_urls(self, mask_type: str) -> PagingList[str]:
def list_mask_urls(self, mask_type: str) -> PagingList[Optional[str]]:
"""List the mask urls in this segment.

Arguments:
Expand Down