@@ -128,9 +128,9 @@ def from_file(
128128
129129 """
130130 if deserializer is None :
131- # Function- scope import to avoid circular dependency. Yucky!!!
132- # TODO: At least move to _get_default_metadata_deserializer helper.
133- from tuf .api .serialization .json import JSONDeserializer # pylint: disable=import-outside-toplevel
131+ # Use local scope import to avoid circular import errors
132+ # pylint: disable=import-outside-toplevel
133+ from tuf .api .serialization .json import JSONDeserializer
134134 deserializer = JSONDeserializer ()
135135
136136 if storage_backend is None :
@@ -171,9 +171,9 @@ def to_file(self, filename: str, serializer: MetadataSerializer = None,
171171
172172 """
173173 if serializer is None :
174- # Function- scope import to avoid circular dependency. Yucky!!!
175- # TODO: At least move to a _get_default_metadata_serializer helper.
176- from tuf .api .serialization .json import JSONSerializer # pylint: disable=import-outside-toplevel
174+ # Use local scope import to avoid circular import errors
175+ # pylint: disable=import-outside-toplevel
176+ from tuf .api .serialization .json import JSONSerializer
177177 serializer = JSONSerializer (True ) # Pass True to compact JSON
178178
179179 with tempfile .TemporaryFile () as temp_file :
@@ -206,10 +206,10 @@ def sign(self, key: JsonDict, append: bool = False,
206206 A securesystemslib-style signature object.
207207
208208 """
209- if serializer is None :
210- # Function- scope import to avoid circular dependency. Yucky!!!
211- # TODO: At least move to a _get_default_signed_serializer helper.
212- from tuf .api .serialization .json import CanonicalJSONSerializer # pylint: disable=import-outside-toplevel
209+ if signed_serializer is None :
210+ # Use local scope import to avoid circular import errors
211+ # pylint: disable=import-outside-toplevel
212+ from tuf .api .serialization .json import CanonicalJSONSerializer
213213 serializer = CanonicalJSONSerializer ()
214214
215215 signature = create_signature (key , serializer .serialize (self .signed ))
@@ -259,9 +259,9 @@ def verify(self, key: JsonDict,
259259 f'{ key ["keyid" ]} , not sure which one to verify.' )
260260
261261 if serializer is None :
262- # Function- scope import to avoid circular dependency. Yucky!!!
263- # TODO: At least move to a _get_default_signed_serializer helper.
264- from tuf .api .serialization .json import CanonicalJSONSerializer # pylint: disable=import-outside-toplevel
262+ # Use local scope import to avoid circular import errors
263+ # pylint: disable=import-outside-toplevel
264+ from tuf .api .serialization .json import CanonicalJSONSerializer
265265 serializer = CanonicalJSONSerializer ()
266266
267267 return verify_signature (
0 commit comments