Skip to content

Commit af94281

Browse files
committed
mypy: remix tree
1 parent 6f2f671 commit af94281

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

scratchattach/site/project.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ def visibility(self):
813813
return requests.get(f"https://api.scratch.mit.edu/users/{self._session.username}/projects/{self.id}/visibility",
814814
headers=self._headers, cookies=self._cookies).json()
815815

816-
def remix_tree(self):
816+
def remix_tree(self) -> Project:
817817
"""
818818
Fetch & cache remix tree, and return remix root.
819819
Cached remix tree children accessible via Project.remix_tree_children.
@@ -866,11 +866,12 @@ def remix_tree(self):
866866
parent_id = curr_data["parent_id"]
867867
if parent := mapping.get(parent_id):
868868
curr_obj.remix_tree_parent = parent
869-
parent.remix_tree_children.append(curr_obj)
869+
# parent cannot be None, as it is the if condition
870+
parent.remix_tree_children.append(curr_obj) # type: ignore
870871

871872
return mapping[root_id]
872873

873-
def remix_tree_pretty(self, indent: int = 0, *, formatter: Callable[[Project, int], str] = None):
874+
def remix_tree_pretty(self, indent: int = 0, *, formatter: Optional[Callable[[Project, int], str]] = None):
874875
"""
875876
Prettily formats and indents the remix tree attached to this project. (does NOT start at root)
876877
:param indent: default indent - recommend keeping this as 0
@@ -883,6 +884,8 @@ def remix_tree_pretty(self, indent: int = 0, *, formatter: Callable[[Project, in
883884
if self.remix_tree_children is None:
884885
self.remix_tree()
885886

887+
assert isinstance(self.remix_tree_children, list)
888+
886889
ret = formatter(self, indent)
887890
for child in self.remix_tree_children:
888891
ret += child.remix_tree_pretty(indent + 1, formatter=formatter)

0 commit comments

Comments
 (0)