cozodb / pycozo

The Python client and Jupyter helper for CozoDB
Mozilla Public License 2.0
47 stars 9 forks source link

pycozo.builder Python 3.9 import error in typing library #8

Open athanhat opened 1 year ago

athanhat commented 1 year ago

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