Skip to content

Tag: abc

Detect incomplete subclass of abstract class, python

In Python, how can I differentiate between a concrete subclass and a subclass which is still abstract (i.e. not all abstract methods have been implemented)? Consider the following: What is the implementation of is_concrete_class? I could attempt to instantiate each subclass given by __subclasses__() and catch…

Distinguishing between Pydantic Models with same fields

I’m using Pydantic to define hierarchical data in which there are models with identical attributes. However, when I save and load these models, Pydantic can no longer distinguish which model was used and picks the first one in the field type annotation. I understand that this is expected behavior based …