Skip to content

Commit

Permalink
Merge pull request #36 from metadsl/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
[pre-commit.ci] pre-commit autoupdate
  • Loading branch information
saulshanabrook authored Aug 8, 2023
2 parents 3df7157 + 9e5dabb commit dfb5785
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
- repo: local
Expand Down
2 changes: 1 addition & 1 deletion python/egglog/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _resolve_literal(tp: TypeOrVarRef, arg: object) -> RuntimeExpr:
else:
arg_type = type(arg)
# If this value has a custom metaclass, let's use that as our index instead of the type
if type(arg_type) != type:
if type(arg_type) != type: # noqa: E721
arg_type = type(arg_type)

# If we have any type variables, dont bother trying to resolve the literal, just return the arg
Expand Down
35 changes: 35 additions & 0 deletions python/tests/test_convert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from egglog import *


def test_conversion_custom_metaclass():
class MyMeta(type):
pass

class MyType(metaclass=MyMeta):
pass

egraph = EGraph()

@egraph.class_
class MyTypeExpr(Expr):
def __init__(self):
...

converter(MyMeta, MyTypeExpr, lambda x: MyTypeExpr())
assert expr_parts(convert(MyType(), MyTypeExpr)) == expr_parts(MyTypeExpr())


def test_conversion():
egraph = EGraph()

class MyType:
pass

@egraph.class_
class MyTypeExpr(Expr):
def __init__(self):
...

converter(MyType, MyTypeExpr, lambda x: MyTypeExpr())

assert expr_parts(convert(MyType(), MyTypeExpr)) == expr_parts(MyTypeExpr())

0 comments on commit dfb5785

Please sign in to comment.