Skip to content

Add context casting functionality #161

Description

@vstolin

Please consider functionality that allows to validate if context A can be cast into context B at model definition time even when there is no direct inheritance between A and B. Consider the following example:

from ccflow import ContextBase

class A(ContextBase):
   foo: str = "x"
class B(ContextBase):
   foo: str = "x"

B.model_validate(A())

This is fully supported use case, but the limitation is that it requires an instance of A(). It would be helpful if we could do something like:

B.context_validate(A)

which returns True if context A can be cast to context B or False otherwise.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions