1717from aiida_restapi .common import errors , query
1818from aiida_restapi .common .pagination import PaginatedResults
1919from aiida_restapi .config import API_CONFIG
20- from aiida_restapi .models .node import MetadataType , NodeModelRegistry , NodeStatistics , NodeType
21- from aiida_restapi .services .node import NodeLink , NodeService
20+ from aiida_restapi .models .node import MetadataType , NodeLink , NodeModelRegistry , NodeStatistics , NodeType
21+ from aiida_restapi .services .node import NodeService
2222
2323from .auth import UserInDB , get_current_active_user
2424
3939
4040@read_router .get (
4141 '/schema' ,
42- response_model = dict ,
42+ response_model = dict [ str , t . Any ] ,
4343 responses = {
4444 422 : {'model' : errors .InvalidNodeTypeError },
4545 },
@@ -56,7 +56,7 @@ async def get_nodes_schema(
5656 t .Literal ['get' , 'post' ],
5757 Query (description = 'Type of schema to retrieve' ),
5858 ] = 'get' ,
59- ) -> dict :
59+ ) -> dict [ str , t . Any ] :
6060 """Get JSON schema for the base AiiDA node 'get' model."""
6161 if not node_type :
6262 return orm .Node .Model .model_json_schema ()
@@ -120,7 +120,7 @@ async def get_nodes(
120120 query .QueryParams ,
121121 Depends (query .query_params ),
122122 ],
123- ) -> PaginatedResults [orm . Node . Model ]:
123+ ) -> PaginatedResults [dict [ str , t . Any ] ]:
124124 """Get AiiDA nodes with optional filtering, sorting, and/or pagination."""
125125 return service .get_many (query_params )
126126
@@ -158,7 +158,7 @@ async def get_node_types() -> list:
158158 },
159159)
160160@with_dbenv ()
161- async def get_node (uuid : str ) -> orm . Node . Model :
161+ async def get_node (uuid : str ) -> dict [ str , t . Any ] :
162162 """Get AiiDA node by uuid."""
163163 return service .get_one (uuid )
164164
@@ -175,9 +175,9 @@ async def get_node(uuid: str) -> orm.Node.Model:
175175 },
176176)
177177@with_dbenv ()
178- async def get_node_user (uuid : str ) -> orm . User . Model :
178+ async def get_node_user (uuid : str ) -> dict [ str , t . Any ] :
179179 """Get the user associated with a node."""
180- return t . cast ( orm . User . Model , service .get_related_one (uuid , orm .User ) )
180+ return service .get_related_one (uuid , orm .User )
181181
182182
183183@read_router .get (
@@ -192,9 +192,9 @@ async def get_node_user(uuid: str) -> orm.User.Model:
192192 },
193193)
194194@with_dbenv ()
195- async def get_node_computer (uuid : str ) -> orm . Computer . Model :
195+ async def get_node_computer (uuid : str ) -> dict [ str , t . Any ] :
196196 """Get the computer associated with a node."""
197- return t . cast ( orm . Computer . Model , service .get_related_one (uuid , orm .Computer ) )
197+ return service .get_related_one (uuid , orm .Computer )
198198
199199
200200@read_router .get (
@@ -215,7 +215,7 @@ async def get_node_groups(
215215 query .QueryParams ,
216216 Depends (query .query_params ),
217217 ],
218- ) -> PaginatedResults [orm . Group . Model ]:
218+ ) -> PaginatedResults [dict [ str , t . Any ] ]:
219219 """Get the groups of a node."""
220220 return service .get_related_many (uuid , orm .Group , query_params )
221221
@@ -272,7 +272,7 @@ async def get_node_links(
272272 query .QueryParams ,
273273 Depends (query .query_params ),
274274 ],
275- ) -> PaginatedResults [NodeLink ]:
275+ ) -> PaginatedResults [dict [ str , t . Any ] ]:
276276 """Get the incoming or outgoing links of a node."""
277277 return service .get_links (uuid , direction , query_params )
278278
@@ -400,7 +400,7 @@ def stream() -> t.Generator[bytes, None, None]:
400400async def create_node (
401401 model : NodeModelUnion ,
402402 current_user : t .Annotated [UserInDB , Depends (get_current_active_user )],
403- ) -> orm . Node . Model :
403+ ) -> dict [ str , t . Any ] :
404404 """Create new AiiDA node."""
405405 return service .add_one (model )
406406
@@ -421,7 +421,7 @@ async def create_node_with_files(
421421 params : t .Annotated [str , Form ()],
422422 files : list [UploadFile ],
423423 current_user : t .Annotated [UserInDB , Depends (get_current_active_user )],
424- ) -> orm . Node . Model :
424+ ) -> dict [ str , t . Any ] :
425425 """Create new AiiDA node with files."""
426426 parameters = t .cast (dict , json .loads (params ))
427427
0 commit comments