Skip to content

[pre-commit.ci] pre-commit autoupdate #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())