Skip to content

Commit bca8b65

Browse files
Try switching entirely to rust
1 parent 4365f3d commit bca8b65

File tree

9 files changed

+489
-385
lines changed

9 files changed

+489
-385
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
; https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8
22
[flake8]
33
max-line-length = 88
4-
extend-ignore = E203,E501,F405,F403,E302
4+
extend-ignore = E203,E501,F405,F403,E302,E305,F821

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
python-version: "3.10"
3939
- uses: actions/checkout@v2
4040
- run: pip install -e . mypy
41-
- run: python -m mypy.stubtest egg_smol.bindings
41+
- run: python -m mypy.stubtest egg_smol.bindings --allowlist stubtest_allow
4242
docs:
4343
runs-on: ubuntu-latest
4444
steps:

python/egg_smol/bindings.pyi

Lines changed: 131 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,119 @@ from typing import Optional
33

44
from typing_extensions import final
55

6-
from .bindings_py import Expr, Fact_, FunctionDecl, Rewrite
6+
@final
7+
class EGraph:
8+
def parse_and_run_program(self, input: str) -> list[str]: ...
9+
def declare_constructor(self, variant: Variant, sort: str) -> None: ...
10+
def declare_sort(self, name: str) -> None: ...
11+
def declare_function(self, decl: FunctionDecl) -> None: ...
12+
def define(self, name: str, expr: _Expr, cost: Optional[int] = None) -> None: ...
13+
def add_rewrite(self, rewrite: Rewrite) -> str: ...
14+
def run_rules(self, limit: int) -> tuple[timedelta, timedelta, timedelta]: ...
15+
def check_fact(self, fact: _Fact) -> None: ...
16+
17+
@final
18+
class EggSmolError(Exception):
19+
context: str
20+
21+
@final
22+
class Int:
23+
def __init__(self, value: int) -> None: ...
24+
value: int
25+
26+
@final
27+
class String:
28+
def __init__(self, value: str) -> None: ...
29+
value: str
30+
31+
@final
32+
class Unit:
33+
def __init__(self) -> None: ...
34+
35+
_Literal = Int | String | Unit
36+
37+
@final
38+
class Lit:
39+
def __init__(self, value: _Literal) -> None: ...
40+
value: _Literal
41+
42+
@final
43+
class Var:
44+
def __init__(self, name: str) -> None: ...
45+
name: str
46+
47+
@final
48+
class Call:
49+
def __init__(self, name: str, args: list[_Expr]) -> None: ...
50+
name: str
51+
args: list[_Expr]
52+
53+
_Expr = Lit | Var | Call
54+
55+
@final
56+
class Eq:
57+
def __init__(self, exprs: list[_Expr]) -> None: ...
58+
exprs: list[_Expr]
59+
60+
@final
61+
class Fact:
62+
def __init__(self, expr: _Expr) -> None: ...
63+
expr: _Expr
64+
65+
_Fact = Fact | Eq
66+
67+
@final
68+
class Define:
69+
def __init__(self, lhs: str, rhs: _Expr) -> None: ...
70+
lhs: str
71+
rhs: _Expr
72+
73+
@final
74+
class Set:
75+
def __init__(self, lhs: str, args: list[_Expr], rhs: _Expr) -> None: ...
76+
lhs: str
77+
args: list[_Expr]
78+
rhs: _Expr
79+
80+
@final
81+
class Delete:
82+
sym: str
83+
args: list[_Expr]
84+
def __init__(self, sym: str, args: list[_Expr]) -> None: ...
85+
86+
@final
87+
class Union:
88+
def __init__(self, lhs: _Expr, rhs: _Expr) -> None: ...
89+
lhs: _Expr
90+
rhs: _Expr
91+
92+
@final
93+
class Panic:
94+
def __init__(self, msg: str) -> None: ...
95+
msg: str
96+
97+
@final
98+
class Expr_:
99+
def __init__(self, expr: _Expr) -> None: ...
100+
expr: _Expr
101+
102+
_Action = Define | Set | Delete | Union | Panic | Expr_
103+
104+
@final
105+
class FunctionDecl:
106+
name: str
107+
schema: Schema
108+
default: Optional[_Expr]
109+
merge: Optional[_Expr]
110+
cost: Optional[int]
111+
def __init__(
112+
self,
113+
name: str,
114+
schema: Schema,
115+
default: Optional[_Expr],
116+
merge: Optional[_Expr],
117+
cost: Optional[int] = None,
118+
) -> None: ...
7119

8120
@final
9121
class Variant:
@@ -15,16 +127,23 @@ class Variant:
15127
cost: Optional[int]
16128

17129
@final
18-
class EGraph:
19-
def parse_and_run_program(self, input: str) -> list[str]: ...
20-
def declare_constructor(self, variant: Variant, sort: str) -> None: ...
21-
def declare_sort(self, name: str) -> None: ...
22-
def declare_function(self, decl: FunctionDecl) -> None: ...
23-
def define(self, name: str, expr: Expr, cost: Optional[int] = None) -> None: ...
24-
def add_rewrite(self, rewrite: Rewrite) -> str: ...
25-
def run_rules(self, limit: int) -> tuple[timedelta, timedelta, timedelta]: ...
26-
def check_fact(self, fact: Fact_) -> None: ...
130+
class Schema:
131+
input: list[str]
132+
output: str
133+
def __init__(self, input: list[str], output: str) -> None: ...
27134

28135
@final
29-
class EggSmolError(Exception):
30-
context: str
136+
class Rule:
137+
head: list[_Action]
138+
body: list[_Fact]
139+
def __init__(self, head: list[_Action], body: list[_Fact]) -> None: ...
140+
141+
@final
142+
class Rewrite:
143+
lhs: _Expr
144+
rhs: _Expr
145+
conditions: list[_Fact]
146+
147+
def __init__(
148+
self, lhs: _Expr, rhs: _Expr, conditions: list[_Fact] = []
149+
) -> None: ...

python/egg_smol/bindings_py.py

Lines changed: 0 additions & 77 deletions
This file was deleted.

python/tests/test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import pytest
44
from egg_smol.bindings import *
5-
from egg_smol.bindings_py import *
65

76

87
class TestEGraph:

0 commit comments

Comments
 (0)