Skip to content

Commit 68e077e

Browse files
[pre-commit.ci] pre-commit autoupdate (#290)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.11.2 → v0.12.7](astral-sh/ruff-pre-commit@v0.11.2...v0.12.7) - [github.com/astral-sh/uv-pre-commit: 0.6.11 → 0.8.4](astral-sh/uv-pre-commit@0.6.11...0.8.4) * Updates for ruff checks * Fix merge conflicts --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Saul Shanabrook <[email protected]>
1 parent 5b25a5e commit 68e077e

File tree

9 files changed

+25
-46
lines changed

9 files changed

+25
-46
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
exclude: ^python/tests/__snapshots__/
22
repos:
33
- repo: https://github.com/astral-sh/ruff-pre-commit
4-
rev: v0.11.2
4+
rev: v0.12.7
55
hooks:
6-
- id: ruff
7-
args: [--fix, --exit-non-zero-on-fix]
6+
- id: ruff-check
7+
args: [--fix]
88
- id: ruff-format
99
- repo: https://github.com/astral-sh/uv-pre-commit
10-
# uv version.
11-
rev: 0.6.11
10+
rev: 0.8.5
1211
hooks:
1312
- id: uv-lock

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,11 @@ ignore = [
199199
# allow blind exception to add context
200200
"BLE001",
201201
# Don't move type checking around so that can be accessed at runtime
202-
"TCH001",
203-
"TCH002",
204-
"TCH003",
202+
"TC001",
203+
"TC002",
204+
"TC003",
205+
# allow eq without hash
206+
"PLW1641",
205207
]
206208
select = ["ALL"]
207209

python/egglog/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
from .conversion import *
99
from .deconstruct import *
1010
from .egraph import *
11-
from .runtime import define_expr_method as define_expr_method # noqa: PLC0414
11+
from .runtime import define_expr_method as define_expr_method
1212

1313
del ipython_magic

python/egglog/egraph.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ def relation(name: str, /, *tps: type, egg_fn: str | None = None) -> Callable[..
688688

689689

690690
def _relation_decls(name: str, tps: tuple[type, ...], egg_fn: str | None) -> Declarations:
691-
from .builtins import Unit
691+
from .builtins import Unit # noqa: PLC0415
692692

693693
decls = Declarations()
694694
decls |= cast("RuntimeClass", Unit)
@@ -1086,9 +1086,9 @@ def display(self, graphviz: bool = False, **kwargs: Unpack[GraphvizKwargs]) -> N
10861086
10871087
If in IPython it will display it inline, otherwise it will write it to a file and open it.
10881088
"""
1089-
from IPython.display import SVG, display
1089+
from IPython.display import SVG, display # noqa: PLC0415
10901090

1091-
from .visualizer_widget import VisualizerWidget
1091+
from .visualizer_widget import VisualizerWidget # noqa: PLC0415
10921092

10931093
if graphviz:
10941094
if IN_IPYTHON:
@@ -1115,7 +1115,7 @@ def saturate(
11151115
11161116
If an `expr` is passed, it's also extracted after each run and printed
11171117
"""
1118-
from .visualizer_widget import VisualizerWidget
1118+
from .visualizer_widget import VisualizerWidget # noqa: PLC0415
11191119

11201120
def to_json() -> str:
11211121
if expr is not None:
@@ -1608,7 +1608,7 @@ class _NeBuilder(Generic[BASE_EXPR]):
16081608
lhs: BASE_EXPR
16091609

16101610
def to(self, rhs: BASE_EXPR) -> Unit:
1611-
from .builtins import Unit
1611+
from .builtins import Unit # noqa: PLC0415
16121612

16131613
lhs = to_runtime_expr(self.lhs)
16141614
rhs = convert_to_same_type(rhs, lhs)

python/egglog/pretty.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -491,24 +491,3 @@ def _pretty_function_body(self, fn: UnnamedFunctionRef, args: list[ExprDecl]) ->
491491
if arg_names:
492492
prefix += f" {', '.join(self(a.expr) for a in arg_names)}"
493493
return f"{prefix}: {self(res.expr)}"
494-
495-
496-
def _plot_line_length(expr: object): # pragma: no cover
497-
"""
498-
Plots the number of line lengths based on different max lengths
499-
"""
500-
global MAX_LINE_LENGTH, LINE_DIFFERENCE
501-
import altair as alt
502-
import pandas as pd
503-
504-
sizes = []
505-
for line_length in range(40, 180, 10):
506-
MAX_LINE_LENGTH = line_length
507-
for diff in range(0, 40, 5):
508-
LINE_DIFFERENCE = diff
509-
new_l = len(str(expr).split())
510-
sizes.append((line_length, diff, new_l))
511-
512-
df = pd.DataFrame(sizes, columns=["MAX_LINE_LENGTH", "LENGTH_DIFFERENCE", "n"])
513-
514-
return alt.Chart(df).mark_rect().encode(x="MAX_LINE_LENGTH:O", y="LENGTH_DIFFERENCE:O", color="n:Q")

python/egglog/runtime.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def __egg_ref__(self) -> CallableRef:
387387
return self.__egg_ref_thunk__()
388388

389389
def __call__(self, *args: object, _egg_partial_function: bool = False, **kwargs: object) -> RuntimeExpr | None:
390-
from .conversion import resolve_literal
390+
from .conversion import resolve_literal # noqa: PLC0415
391391

392392
if isinstance(self.__egg_bound__, RuntimeExpr):
393393
args = (self.__egg_bound__, *args)
@@ -540,7 +540,7 @@ def __egg_pretty__(self, wrapping_fn: str | None) -> str:
540540
return pretty_decl(self.__egg_decls__, self.__egg_typed_expr__.expr, wrapping_fn=wrapping_fn)
541541

542542
def _ipython_display_(self) -> None:
543-
from IPython.display import Code, display
543+
from IPython.display import Code, display # noqa: PLC0415
544544

545545
display(Code(str(self), language="python"))
546546

@@ -577,15 +577,15 @@ def __eq__(self, other: object) -> object: # type: ignore[override]
577577

578578
# TODO: Check if two objects can be upcasted to be the same. If not, then return NotImplemented so other
579579
# expr gets a chance to resolve __eq__ which could be a preserved method.
580-
from .egraph import BaseExpr, eq
580+
from .egraph import BaseExpr, eq # noqa: PLC0415
581581

582582
return eq(cast("BaseExpr", self)).to(cast("BaseExpr", other))
583583

584584
def __ne__(self, other: object) -> object: # type: ignore[override]
585585
if (method := _get_expr_method(self, "__ne__")) is not None:
586586
return method(other)
587587

588-
from .egraph import BaseExpr, ne
588+
from .egraph import BaseExpr, ne # noqa: PLC0415
589589

590590
return ne(cast("BaseExpr", self)).to(cast("BaseExpr", other))
591591

@@ -647,7 +647,7 @@ def _numeric_binary_method(self: object, other: object, name: str = name, r_meth
647647
)
648648
)
649649
):
650-
from .conversion import CONVERSIONS, resolve_type, retrieve_conversion_decls
650+
from .conversion import CONVERSIONS, resolve_type, retrieve_conversion_decls # noqa: PLC0415
651651

652652
# tuple of (cost, convert_self)
653653
best_method: (

python/egglog/version_compat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _collect_type_vars_monkeypatch(types_, typevar_types=None):
3030
3131
_collect_type_vars((T, List[S, T])) == (T, S)
3232
"""
33-
from .runtime import RuntimeClass
33+
from .runtime import RuntimeClass # noqa: PLC0415
3434

3535
if typevar_types is None:
3636
typevar_types = typing.TypeVar
@@ -48,7 +48,7 @@ def _collect_type_vars_monkeypatch(types_, typevar_types=None):
4848
@typing.no_type_check
4949
@typing._tp_cache
5050
def __getitem__monkeypatch(self, params): # noqa: C901, PLR0912
51-
from .runtime import RuntimeClass
51+
from .runtime import RuntimeClass # noqa: PLC0415
5252

5353
if self.__origin__ in (typing.Generic, typing.Protocol):
5454
# Can't subscript Generic[...] or Protocol[...].

python/tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
import pytest
44
from syrupy.extensions.single_file import SingleFileSnapshotExtension
55

6+
import egglog.conversion
7+
68

79
@pytest.fixture(autouse=True)
810
def _reset_conversions():
9-
import egglog.conversion
10-
1111
old_conversions = copy.copy(egglog.conversion.CONVERSIONS)
1212
old_conversion_decls = copy.copy(egglog.conversion._TO_PROCESS_DECLS)
1313
yield

python/tests/test_unstable_fn.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from typing import ClassVar, TypeAlias
1111

1212
from egglog import *
13+
from egglog.runtime import RuntimeFunction
1314

1415

1516
class Math(Expr):
@@ -167,8 +168,6 @@ def __init__(self) -> None: ...
167168

168169

169170
def test_callable_accepted_as_type():
170-
from egglog.runtime import RuntimeFunction
171-
172171
@function
173172
def func(f: UnstableFn[C, A, B]) -> C: ...
174173

0 commit comments

Comments
 (0)