22
33from __future__ import annotations
44
5- from typing import Any
5+ from typing import TYPE_CHECKING , Any
66
77import graphene
88from graphene .types .generic import GenericScalar
99from graphql_relay import to_global_id
1010
11+ if TYPE_CHECKING :
12+ from config .graphql .annotation_types import AnnotationType
13+ from config .graphql .corpus_types import CorpusFolderType
14+ from config .graphql .user_types import UserType
15+
1116
1217def build_flat_tree (
1318 nodes : list [dict [str , Any ]],
@@ -31,7 +36,7 @@ def build_flat_tree(
3136 - "children": list of child node global IDs.
3237 """
3338 # Map node IDs to their immediate children IDs
34- id_to_children : dict [Any , list [Any ]] = {}
39+ id_to_children : dict [int | str , list [int | str ]] = {}
3540 for node in nodes :
3641 node_id = node ["id" ]
3742 parent_id = node ["parent_id" ]
@@ -231,19 +236,19 @@ class PageAwareAnnotationType(graphene.ObjectType):
231236 page_annotations = graphene .List (lambda : _get_annotation_type ())
232237
233238
234- def _get_user_type () -> type :
239+ def _get_user_type () -> type [ UserType ] :
235240 from config .graphql .user_types import UserType
236241
237242 return UserType
238243
239244
240- def _get_corpus_folder_type () -> type :
245+ def _get_corpus_folder_type () -> type [ CorpusFolderType ] :
241246 from config .graphql .corpus_types import CorpusFolderType
242247
243248 return CorpusFolderType
244249
245250
246- def _get_annotation_type () -> type :
251+ def _get_annotation_type () -> type [ AnnotationType ] :
247252 from config .graphql .annotation_types import AnnotationType
248253
249254 return AnnotationType
0 commit comments