1616from math import isclose
1717from pathlib import Path
1818from tempfile import gettempdir
19- from typing import TYPE_CHECKING , Literal , overload
19+ from typing import TYPE_CHECKING , Literal , cast , overload
2020from urllib .parse import urlsplit
2121
2222import orjson
6969
7070if TYPE_CHECKING :
7171 from collections .abc import Generator , Iterable , Sequence
72- from typing import Any , cast
72+ from typing import Any
7373
7474 from mp_api .client .contribs .types import (
7575 AllIdMap ,
@@ -1419,6 +1419,7 @@ def _collect_ids_as_sets(
14191419 components : set [str ],
14201420 data_id_fields : dict [str , str ],
14211421 ) -> AllIdSets :
1422+
14221423 ret : AllIdSets = {}
14231424
14241425 for contrib in contributions :
@@ -1432,13 +1433,12 @@ def _collect_ids_as_sets(
14321433 ret [project ] = id_sets
14331434
14341435 project_sets = ret [project ]
1435- if TYPE_CHECKING :
1436- cast (set [str ], project_sets ["ids" ]).add (contrib ["id" ])
1437- cast (set [str ], project_sets ["identifiers" ]).add (contrib ["identifier" ])
1436+ cast (set [str ], project_sets ["ids" ]).add (contrib ["id" ])
1437+ cast (set [str ], project_sets ["identifiers" ]).add (contrib ["identifier" ])
14381438
14391439 if data_id_field :
14401440 data_value = contrib .get ("data" , {}).get (data_id_field )
1441- if TYPE_CHECKING and isinstance (data_value , str ):
1441+ if isinstance (data_value , str ):
14421442 cast (set [str ], project_sets [f"{ data_id_field } _set" ]).add (data_value )
14431443
14441444 for component in components :
@@ -1449,8 +1449,7 @@ def _collect_ids_as_sets(
14491449 if component not in project_sets :
14501450 project_sets [component ] = {"ids" : set (), "md5s" : set ()}
14511451
1452- if TYPE_CHECKING :
1453- component_sets = cast (ComponentIdSets , project_sets [component ])
1452+ component_sets = cast (ComponentIdSets , project_sets [component ])
14541453
14551454 for item in component_items :
14561455 if not isinstance (item , dict ):
0 commit comments