Metadata API: Metadata "factory" constructors misbehave with inheritance
See original GitHub issueclass DerivedMetadata(Metadata):
def ok(self):
print("ok")
md = DerivedMetadata.from_file("root.json")
md.ok() # fails because md type is Metadata, not DerivedMetadata
This seems to happen because the construction path goes
- DerivedMetadata.from_file()
- DerivedMetadata.from_bytes()
- JsonDeserializer.deserialize() here deserializer doesn’t know the correct class anymore and calls Metadata.from_dict()
- Metadata.from_dict()
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (10 by maintainers)
Top Results From Across the Web
A tour of the Dart language
This page shows you how to use each major Dart feature, from variables and operators to classes and libraries, with the assumption that...
Read more >Static factory pattern with inheritance and type hints
I want both of them to use the static factory pattern (or "named constructors"). I've seen some examples of that pattern, but none...
Read more >How do I pick a service implementation by context?
Option 4: Use Metadata ... We just use the correct base class in the constructor: ... You can associate metadata with registrations directly:....
Read more >What's new in .NET Framework - Microsoft Learn
Windows Forms is a thin managed wrapper around the Windows API, ... the client retrieves parameter metadata from the server only once.
Read more >EclipseLink | Development | JPA 2.0 - Eclipsepedia
1) The Metamodel API exposes the entity annotation API and the XML mapping API as one unified "metadata" type-safe API. 2) The Metamodel...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jku, unless you need this resolved quickly, I think it would be a good self-contained task for someone to get started with python-tuf development. AFAICS what’s missing is:
MetadataDeserializer
accordingly (beware of type check case handling and cyclic-imports!)so it should mean Metadata is a Generic, and it’s generic over the type T – this is often used to mean that the Generic is container for type T, as it is here (even if our container is a bit unique in that there is always one and only one T in Metadata).