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

Fix type-checker erros when using Control, Model or SolveHandle #106

Closed florianfischer91 closed 2 years ago

florianfischer91 commented 2 years ago

Because of the redefinition of Control Model and SolveHandle (and therefore the ambigouity between clorm and clingo) for type-checkers like mypy or pyright it wasn't possible to handle them properly f.i. they weren't aware of the additional added methods like add_facts or the extra argument unifier of Control.__init__.

To solve this problem without introduce breaking changes, we move the redefinitions into a separate file clorm._clingo.py and export the classes in clorm.clingo.py twice, once with the name how they are defined in clingo and once with the original name.

In this way users how want to use type-checkers can import f.i. ClormControl whereas users how don't use type-checkers or can't change the name can still use Control (which is also a ClormControl class)