potassco / clorm

🗃️ A Python ORM-like interface for the Clingo Answer Set Programming (ASP) reasoner
https://clorm.readthedocs.io
MIT License
52 stars 5 forks source link

add support for 'from __future__ import annotations' #131

Closed florianfischer91 closed 6 months ago

florianfischer91 commented 7 months ago

hopefully fixes #129

daveraja commented 6 months ago

Thanks @florianfischer9. I've been struggling with this trying to understand the pydantic v2 code.

I think there are still boundary cases. For example,

from __future__ import annotations
from clorm import Predicate, ConstantStr

def test_basic_import():
    class P(Predicate):
        i: int
        c: ConstantStr

    class Q(Predicate):
        i: int
        p: P

    p = P(i=1,c="a")
    q = Q(i=1,p=p)

But I think this is not how we typically define the clorm schemas so hopefully this solution handles most realistic use-cases. In any case it gives me something to build on. Thanks.