cozodb/pycozo

pycozo.builder Python 3.9 import error in typing library

Opened this issue · 0 comments

Hi, I have tried to work with pycozo.builder to construct CozoScript (0.7.2) queries programmatically.

from pycozo.builder import (Var, Const, 
                            InputParam, InputObject, InputList, InputRelation, InputProgram,
                            OpApply, Sorter, RuleHead, RuleApply, ProximityApply, 
                            StoreOp, StoredRuleApply, StoredRuleNamedApply,    
                            Conjunction, Disjunction, Negation, Bind, Cond, RawAtom,
                            FixedRule, InlineRule, ConstantRule)

ImportError                               Traceback (most recent call last)
Cell In[2], line 1
----> 1 from pycozo.builder import (Var, Const, 
      2                             InputParam, InputObject, InputList, InputRelation, InputProgram,
      3                             OpApply, Sorter, RuleHead, RuleApply, ProximityApply, 
      4                             StoreOp, StoredRuleApply, StoredRuleNamedApply,    
      5                             Conjunction, Disjunction, Negation, Bind, Cond, RawAtom,
      6                             FixedRule, InlineRule, ConstantRule)

File ~/anaconda3/envs/KGTK/lib/python3.9/site-packages/pycozo/builder.py:9
      7 from enum import Enum
      8 from dataclasses import dataclass, field
----> 9 from typing import Any, TypeAlias, Union
     12 @dataclass
     13 class Var:
     14     name: str

ImportError: cannot import name 'TypeAlias' from 'typing' (~/anaconda3/envs/KGTK/lib/python3.9/typing.py)

NOTICE: The python environment that I tried the script above is based on Python 3.9, I have also tried with Python 3.10 and the problem with typing library disappeared. Code in test_builder.py works fine with Python 3.10