Point72 / Point72/ccflow

Add context casting functionality

Open
#161 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
44
Forks
7
Avg merge
17h 16m
Merged PRs (30d)
13

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at ContextBase and the existing model_validate path to understand how one context is cast into another without an instance. Define the expected class-level behavior for compatible and incompatible contexts, then verify that context_validate(A) returns the corresponding boolean for the example and its failure cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.