chore: add Ruff and apply formatting across codebase
Introduce ruff lint/format config, expand .gitignore, and reformat Python sources. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+2
-5
@@ -20,10 +20,7 @@ def make_png(
|
||||
crc = zlib.crc32(tag + data) & 0xFFFFFFFF
|
||||
return struct.pack(">I", len(data)) + tag + data + struct.pack(">I", crc)
|
||||
|
||||
raw = b"".join(
|
||||
b"\x00" + bytes([r, g, b] * width)
|
||||
for _ in range(height)
|
||||
)
|
||||
raw = b"".join(b"\x00" + bytes([r, g, b] * width) for _ in range(height))
|
||||
compressed = zlib.compress(raw, 9)
|
||||
ihdr = struct.pack(">IIBBBBB", width, height, 8, 2, 0, 0, 0)
|
||||
png = (
|
||||
@@ -37,7 +34,7 @@ def make_png(
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _ensure_builtin_modules() -> None:
|
||||
import imagepipeline.modules # noqa: F401
|
||||
pass # noqa: F401
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -110,9 +110,7 @@ class TestAIParameters:
|
||||
assert payload["modalities"] == ["image"]
|
||||
assert payload["image_config"] == {"strength": 0.25}
|
||||
|
||||
def test_save_result_matching_source_preserves_png_size(
|
||||
self, tmp_path: Path
|
||||
) -> None:
|
||||
def test_save_result_matching_source_preserves_png_size(self, tmp_path: Path) -> None:
|
||||
try:
|
||||
from PIL import Image
|
||||
except ImportError:
|
||||
|
||||
+13
-5
@@ -113,9 +113,11 @@ class TestPipelineRunner:
|
||||
for src in ctx.input_paths:
|
||||
shutil.copy2(src, ctx.output_dir / src.name)
|
||||
|
||||
with Pipeline(name="order_test", input_dir=input_dir, output_base=output_base, verbose=False) as p:
|
||||
with Pipeline(
|
||||
name="order_test", input_dir=input_dir, output_base=output_base, verbose=False
|
||||
) as p:
|
||||
step_b = p.step("order_tracker", inputs="input")
|
||||
step_a = p.step("order_tracker", inputs=step_b)
|
||||
p.step("order_tracker", inputs=step_b)
|
||||
p.run()
|
||||
|
||||
assert order == ["order_tracker_01", "order_tracker_02"]
|
||||
@@ -132,7 +134,9 @@ class TestPipelineRunner:
|
||||
for src in ctx.input_paths:
|
||||
shutil.copy2(src, ctx.output_dir / src.name)
|
||||
|
||||
with Pipeline(name="dup_test", input_dir=input_dir, output_base=output_base, verbose=False) as p:
|
||||
with Pipeline(
|
||||
name="dup_test", input_dir=input_dir, output_base=output_base, verbose=False
|
||||
) as p:
|
||||
first = p.step("number_tracker", inputs="input")
|
||||
p.step("number_tracker", inputs=first)
|
||||
root = p.run()
|
||||
@@ -170,7 +174,9 @@ class TestCustomStepId:
|
||||
for src in ctx.input_paths:
|
||||
shutil.copy2(src, ctx.output_dir / src.name)
|
||||
|
||||
with Pipeline(name="named_test", input_dir=input_dir, output_base=output_base, verbose=False) as p:
|
||||
with Pipeline(
|
||||
name="named_test", input_dir=input_dir, output_base=output_base, verbose=False
|
||||
) as p:
|
||||
ref = p.step("named_tracker", inputs="input", step_id="input_bokeh")
|
||||
root = p.run()
|
||||
|
||||
@@ -193,7 +199,9 @@ class TestCustomStepId:
|
||||
for src in ctx.input_paths:
|
||||
shutil.copy2(src, ctx.output_dir / src.name)
|
||||
|
||||
with Pipeline(name="counter_test", input_dir=input_dir, output_base=output_base, verbose=False) as p:
|
||||
with Pipeline(
|
||||
name="counter_test", input_dir=input_dir, output_base=output_base, verbose=False
|
||||
) as p:
|
||||
p.step("counter_tracker", inputs="input")
|
||||
p.step("counter_tracker", inputs="input", step_id="custom_mid")
|
||||
p.step("counter_tracker", inputs="input")
|
||||
|
||||
@@ -13,7 +13,6 @@ from imagepipeline.core.resume import (
|
||||
)
|
||||
from imagepipeline.core.step import StepDefinition
|
||||
from imagepipeline.modules.imagemagick_grayscale import ImageMagickGrayscale
|
||||
from imagepipeline.modules.registry import get_module
|
||||
from imagepipeline.modules.rembg import RembgModule
|
||||
from imagepipeline.utils.gmic import finalize_gmic_output, split_gmic_command
|
||||
from tests.conftest import make_png
|
||||
@@ -124,7 +123,9 @@ class TestExpectedOutputFilenames:
|
||||
|
||||
class TestPipelineResume:
|
||||
@pytest.mark.skipif(not shutil.which("magick"), reason="ImageMagick not installed")
|
||||
def test_continue_skips_completed_steps(self, input_dir: Path, output_base: Path, capsys) -> None:
|
||||
def test_continue_skips_completed_steps(
|
||||
self, input_dir: Path, output_base: Path, capsys
|
||||
) -> None:
|
||||
with Pipeline(
|
||||
name="resume_test",
|
||||
input_dir=input_dir,
|
||||
@@ -195,9 +196,7 @@ class TestPipelineResume:
|
||||
verbose=True,
|
||||
existing_outputs={"input_bokeh": external},
|
||||
) as p:
|
||||
reused = p.step(
|
||||
"imagemagick_grayscale", inputs="input", step_id="input_bokeh"
|
||||
)
|
||||
reused = p.step("imagemagick_grayscale", inputs="input", step_id="input_bokeh")
|
||||
p.step("imagemagick_grayscale", inputs=reused)
|
||||
root = p.run()
|
||||
|
||||
|
||||
@@ -119,9 +119,7 @@ def _make_stack_fixture(tmp_path: Path) -> dict[str, Path]:
|
||||
|
||||
class TestXcfStackRun:
|
||||
@patch("imagepipeline.modules.xcf_stack.stack_images_to_xcf")
|
||||
def test_collects_layers_from_explicit_inputs(
|
||||
self, mock_stack: object, tmp_path: Path
|
||||
) -> None:
|
||||
def test_collects_layers_from_explicit_inputs(self, mock_stack: object, tmp_path: Path) -> None:
|
||||
paths = _make_stack_fixture(tmp_path)
|
||||
input_path = paths["root"] / "refs" / "photo.jpg"
|
||||
input_path.parent.mkdir()
|
||||
@@ -152,9 +150,7 @@ class TestXcfStackRun:
|
||||
]
|
||||
|
||||
@patch("imagepipeline.modules.xcf_stack.stack_images_to_xcf")
|
||||
def test_skip_missing_true_skips_missing_step(
|
||||
self, mock_stack: object, tmp_path: Path
|
||||
) -> None:
|
||||
def test_skip_missing_true_skips_missing_step(self, mock_stack: object, tmp_path: Path) -> None:
|
||||
paths = _make_stack_fixture(tmp_path)
|
||||
(paths["step_b"] / "photo.png").unlink()
|
||||
input_path = paths["root"] / "photo.jpg"
|
||||
|
||||
Reference in New Issue
Block a user