Skip to content

Commit 265a954

Browse files
Ignore flake8 error and add tests
1 parent 6e9e3e2 commit 265a954

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

python/egglog/runtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def _resolve_literal(tp: TypeOrVarRef, arg: object) -> RuntimeExpr:
9494
else:
9595
arg_type = type(arg)
9696
# If this value has a custom metaclass, let's use that as our index instead of the type
97-
if type(arg_type) != type:
97+
if type(arg_type) != type: # noqa: E721
9898
arg_type = type(arg_type)
9999

100100
# If we have any type variables, dont bother trying to resolve the literal, just return the arg

python/tests/test_convert.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import numpy as np
2+
from egglog import *
3+
from egglog.runtime import CONVERSIONS
4+
5+
6+
def test_conversion_custom_metaclass():
7+
class MyMeta(type):
8+
pass
9+
10+
class MyType(metaclass=MyMeta):
11+
pass
12+
13+
egraph = EGraph()
14+
15+
@egraph.class_
16+
class MyTypeExpr(Expr):
17+
def __init__(self):
18+
...
19+
20+
converter(MyMeta, MyTypeExpr, lambda x: MyTypeExpr())
21+
print(CONVERSIONS)
22+
assert expr_parts(convert(MyType(), MyTypeExpr)) == expr_parts(MyTypeExpr())
23+
24+
25+
def test_conversion():
26+
egraph = EGraph()
27+
28+
class MyType:
29+
pass
30+
31+
@egraph.class_
32+
class MyTypeExpr(Expr):
33+
def __init__(self):
34+
...
35+
36+
converter(MyType, MyTypeExpr, lambda x: MyTypeExpr())
37+
38+
assert expr_parts(convert(MyType(), MyTypeExpr)) == expr_parts(MyTypeExpr())

0 commit comments

Comments
 (0)