Skip to content

Commit ba6c672

Browse files
committed
Use Generic type T in return types
Modify the return type of the Metadata factory methods (from_*) to use the Generic type T. This helps IDEs understand the return type and give proper hints. The static method from_bytes() has to become a class method to get the needed Generic info. Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
1 parent 6aa5727 commit ba6c672

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tuf/api/metadata.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __init__(self, signed: T, signatures: "OrderedDict[str, Signature]"):
8080
self.signatures = signatures
8181

8282
@classmethod
83-
def from_dict(cls, metadata: Dict[str, Any]) -> "Metadata":
83+
def from_dict(cls, metadata: Dict[str, Any]) -> "Metadata[T]":
8484
"""Creates Metadata object from its dict representation.
8585
8686
Arguments:
@@ -133,7 +133,7 @@ def from_file(
133133
filename: str,
134134
deserializer: Optional[MetadataDeserializer] = None,
135135
storage_backend: Optional[StorageBackendInterface] = None,
136-
) -> "Metadata":
136+
) -> "Metadata[T]":
137137
"""Loads TUF metadata from file storage.
138138
139139
Arguments:
@@ -160,11 +160,12 @@ def from_file(
160160
with storage_backend.get(filename) as file_obj:
161161
return cls.from_bytes(file_obj.read(), deserializer)
162162

163-
@staticmethod
163+
@classmethod
164164
def from_bytes(
165+
cls,
165166
data: bytes,
166167
deserializer: Optional[MetadataDeserializer] = None,
167-
) -> "Metadata":
168+
) -> "Metadata[T]":
168169
"""Loads TUF metadata from raw data.
169170
170171
Arguments:

0 commit comments

Comments
 (0)