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

Dealing with postponed evaluation of annotations #129

Closed daveraja closed 6 months ago

daveraja commented 11 months ago

Postponed evaluation of annotations is documented in PEP 563 https://peps.python.org/pep-0563/

Postponed evaluation of annotations can be enabled with from __future__ import annotations and will become mandatory in some future version of Python.

The basic idea is that when the annotation is evaluated at runtime, it will appear as a string and not as the types that the strings represent. Because of this, using annotations for defining Predicate sub-classes or using annotations with function signature to define '@' ASP functions breaks when postponed evaluation of annotations is enabled.

Dealing with this in Clorm may not be straightforward. See this Pydantic issue for some discussion: https://github.com/pydantic/pydantic/issues/2678. I think some of the issues raised could also apply to Clorm.