@@ -128,9 +128,9 @@ def from_file(
128
128
129
129
"""
130
130
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
134
134
deserializer = JSONDeserializer ()
135
135
136
136
if storage_backend is None :
@@ -171,9 +171,9 @@ def to_file(self, filename: str, serializer: MetadataSerializer = None,
171
171
172
172
"""
173
173
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
177
177
serializer = JSONSerializer (True ) # Pass True to compact JSON
178
178
179
179
with tempfile .TemporaryFile () as temp_file :
@@ -206,10 +206,10 @@ def sign(self, key: JsonDict, append: bool = False,
206
206
A securesystemslib-style signature object.
207
207
208
208
"""
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
213
213
serializer = CanonicalJSONSerializer ()
214
214
215
215
signature = create_signature (key , serializer .serialize (self .signed ))
@@ -259,9 +259,9 @@ def verify(self, key: JsonDict,
259
259
f'{ key ["keyid" ]} , not sure which one to verify.' )
260
260
261
261
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
265
265
serializer = CanonicalJSONSerializer ()
266
266
267
267
return verify_signature (
0 commit comments