@@ -170,6 +170,9 @@ class LegacyService:
170170 'entity_types' ,
171171 'fields' ,
172172 },
173+ 'arg_types' : {
174+ 'organisms' : int ,
175+ },
173176 'select' : {
174177 'genesymbols' : {'source_genesymbol' , 'target_genesymbol' },
175178 'organism' : {'ncbi_tax_id_source' , 'ncbi_tax_id_target' },
@@ -1153,7 +1156,7 @@ def _update_resources(self):
11531156 _log ('Finished updating resource information.' )
11541157
11551158
1156- def _clean_args (self , args : dict ) -> dict :
1159+ def _clean_args (self , args : dict , query_type : QUERY_TYPES ) -> dict :
11571160 """
11581161 Removes empty arguments, `kwargs` and `self` to prepare them for
11591162 generating the SQL query.
@@ -1174,10 +1177,31 @@ def _clean_args(self, args: dict) -> dict:
11741177 if v is not None
11751178 }
11761179 args ['format' ] = self ._ensure_str (args .get ('format' ))
1180+ args = {
1181+ k : self ._ensure_type (v , k , query_type )
1182+ for k , v in args .items ()
1183+ }
11771184
11781185 return args
11791186
11801187
1188+ def _ensure_type (val : Any , name : str , query_type : QUERY_TYPES ) -> Any :
1189+
1190+ typ = self .query_param [query_type ].get ('arg_types' , {}).get (name )
1191+
1192+ if typ is not None :
1193+
1194+ if isinstance (val , _const .LIST_LIKE ):
1195+
1196+ val = [typ (x ) for x in val ]
1197+
1198+ else :
1199+
1200+ val = typ (val )
1201+
1202+ return val
1203+
1204+
11811205 def _maybe_bool (self , val : Any ) -> Any :
11821206 """
11831207 Checks whether a variable is any alternative representation of a boolean
@@ -1879,7 +1903,7 @@ def _request(
18791903 """
18801904
18811905 fields_to_remove = args .pop ('fields_to_remove' , set ())
1882- args = self ._clean_args (args )
1906+ args = self ._clean_args (args , query_type )
18831907 args = self ._array_args (args , query_type )
18841908 query , bad_req = self ._query (
18851909 args ,
0 commit comments