Skip to content

Fix lint errors #2

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 1 commit into from
May 25, 2025
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
5 changes: 1 addition & 4 deletions src/nodetool/dsl/lib/grid.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from pydantic import BaseModel, Field
import typing
from typing import Any
import nodetool.metadata.types
from pydantic import Field
import nodetool.metadata.types as types
from nodetool.dsl.graph import GraphNode

Expand Down
4 changes: 1 addition & 3 deletions src/nodetool/dsl/lib/ocr.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from pydantic import BaseModel, Field
from pydantic import Field
import typing
from typing import Any
import nodetool.metadata.types
import nodetool.metadata.types as types
from nodetool.dsl.graph import GraphNode

Expand Down
5 changes: 1 addition & 4 deletions src/nodetool/dsl/lib/pillow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from pydantic import BaseModel, Field
import typing
from typing import Any
import nodetool.metadata.types
from pydantic import Field
import nodetool.metadata.types as types
from nodetool.dsl.graph import GraphNode

Expand Down
9 changes: 2 additions & 7 deletions src/nodetool/dsl/lib/pillow/draw.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from pydantic import BaseModel, Field
from pydantic import Field
import typing
from typing import Any
import nodetool.metadata.types
import nodetool.metadata.types as types
from nodetool.dsl.graph import GraphNode
import nodetool.nodes.lib.pillow.draw # noqa: E402


class Background(GraphNode):
Expand Down Expand Up @@ -64,10 +63,6 @@ def get_node_type(cls):
return "lib.pillow.draw.GaussianNoise"


import nodetool.nodes.lib.pillow.draw
import nodetool.nodes.lib.pillow.draw


class RenderText(GraphNode):
"""
This node allows you to add text to images.
Expand Down
5 changes: 1 addition & 4 deletions src/nodetool/dsl/lib/pillow/enhance.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from pydantic import BaseModel, Field
import typing
from typing import Any
import nodetool.metadata.types
from pydantic import Field
import nodetool.metadata.types as types
from nodetool.dsl.graph import GraphNode

Expand Down
8 changes: 2 additions & 6 deletions src/nodetool/dsl/lib/pillow/filter.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from pydantic import BaseModel, Field
from pydantic import Field
import typing
from typing import Any
import nodetool.metadata.types
import nodetool.metadata.types as types
from nodetool.dsl.graph import GraphNode
import nodetool.nodes.lib.pillow.filter # noqa: E402


class Blur(GraphNode):
Expand Down Expand Up @@ -161,9 +160,6 @@ def get_node_type(cls):
return "lib.pillow.filter.FindEdges"


import nodetool.nodes.lib.pillow.filter


class GetChannel(GraphNode):
"""
Extract a specific color channel from an image.
Expand Down
12 changes: 3 additions & 9 deletions src/nodetool/dsl/lib/svg.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from pydantic import BaseModel, Field
from pydantic import Field
from pydantic.fields import PydanticUndefined
import typing
from typing import Any
import nodetool.metadata.types
import nodetool.metadata.types as types
from nodetool.dsl.graph import GraphNode
import nodetool.nodes.lib.svg # noqa: E402


class CircleNode(GraphNode):
Expand Down Expand Up @@ -165,9 +165,6 @@ def get_node_type(cls):
return "lib.svg.GaussianBlur"


import nodetool.nodes.lib.svg


class Gradient(GraphNode):
"""
Create linear or radial gradients for SVG elements.
Expand Down Expand Up @@ -358,9 +355,6 @@ def get_node_type(cls):
return "lib.svg.SVGToImage"


import nodetool.nodes.lib.svg


class Text(GraphNode):
"""
Add text elements to SVG.
Expand Down
5 changes: 3 additions & 2 deletions src/nodetool/nodes/lib/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
import PIL.Image
from nodetool.workflows.base_node import BaseNode
from nodetool.workflows.processing_context import ProcessingContext
from nodetool.metadata.types import ImageRef, Field
from nodetool.metadata.types import ImageRef
from pydantic import Field

from typing import List
from PIL import Image, ImageChops, ImageDraw
from PIL import Image, ImageDraw


class Tile:
Expand Down
1 change: 0 additions & 1 deletion src/nodetool/nodes/lib/ocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from nodetool.workflows.processing_context import ProcessingContext
from nodetool.workflows.base_node import BaseNode
from nodetool.workflows.types import NodeUpdate
from nodetool.workflows.processing_context import ProcessingContext
from nodetool.metadata.types import ImageRef, OCRResult
from paddleocr import PaddleOCR

Expand Down
1 change: 0 additions & 1 deletion src/nodetool/nodes/lib/pillow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import Any
from nodetool.workflows.processing_context import ProcessingContext
from nodetool.metadata.types import ImageRef
from nodetool.workflows.base_node import BaseNode
Expand Down
1 change: 0 additions & 1 deletion src/nodetool/nodes/lib/pillow/draw.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from enum import Enum
import PIL.Image
import PIL.ImageDraw
Expand Down
19 changes: 12 additions & 7 deletions src/nodetool/nodes/lib/pillow/enhance.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import PIL.Image
import PIL.ImageOps
import PIL.ImageFilter
import PIL.ImageEnhance
import PIL.ImageFilter
import PIL.ImageOps
import numpy as np

from nodetool.metadata.types import Field, ImageRef
from nodetool.metadata.types import ImageRef
from nodetool.workflows.base_node import BaseNode
from nodetool.workflows.processing_context import ProcessingContext
from pydantic import Field
Expand All @@ -20,12 +20,12 @@ def adaptive_contrast(
# Convert image from BGR to LAB color model
img_lab = cv2.cvtColor(img, cv2.COLOR_BGR2Lab)

# Split the LAB image into L, A and B channels
l, a, b = cv2.split(img_lab)
# Split the LAB image into L, A, and B channels
l_channel, a, b = cv2.split(img_lab)

# Perform histogram equalization only on the L channel
clahe = cv2.createCLAHE(clipLimit=clip_limit, tileGridSize=(grid_size, grid_size))
cl = clahe.apply(l)
cl = clahe.apply(l_channel)

# Merge the CLAHE enhanced L channel with the original A and B channel
merged_channels = cv2.merge((cl, a, b))
Expand Down Expand Up @@ -72,7 +72,12 @@ class AutoContrast(BaseNode):
image: ImageRef = Field(
default=ImageRef(), description="The image to adjust the contrast for."
)
cutoff: int = Field(default=0, ge=0, le=255, description="Represents the percentage of pixels to ignore at both the darkest and lightest ends of the histogram. A cutoff value of 5 means ignoring the darkest 5% and the lightest 5% of pixels, enhancing overall contrast by stretching the remaining pixel values across the full brightness range.")
cutoff: int = Field(
default=0,
ge=0,
le=255,
description="Represents the percentage of pixels to ignore at both the darkest and lightest ends of the histogram. A cutoff value of 5 means ignoring the darkest 5% and the lightest 5% of pixels, enhancing overall contrast by stretching the remaining pixel values across the full brightness range.",
)

async def process(self, context: ProcessingContext) -> ImageRef:
image = await context.image_to_pil(self.image)
Expand Down
2 changes: 0 additions & 2 deletions src/nodetool/nodes/lib/pillow/filter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from enum import Enum
import PIL.Image
import PIL.ImageDraw
Expand All @@ -13,7 +12,6 @@
from nodetool.metadata.types import ImageRef
from nodetool.workflows.base_node import BaseNode
from pydantic import Field
from typing import Literal


class Invert(BaseNode):
Expand Down
6 changes: 2 additions & 4 deletions src/nodetool/nodes/lib/svg.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import os
from enum import Enum
import PIL.Image
import io
from typing import Literal, Optional
from pydantic import BaseModel, Field
import PIL.Image
from pydantic import Field
from nodetool.workflows.base_node import BaseNode
from nodetool.workflows.processing_context import ProcessingContext
from nodetool.metadata.types import ColorRef, ImageRef, SVGRef, SVGElement
Expand Down
1 change: 0 additions & 1 deletion tests/image/test_grid.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest
from typing import List, Tuple
from PIL import Image
import numpy as np

from nodetool.nodes.lib.grid import Tile, combine_grid, make_grid

Expand Down
1 change: 0 additions & 1 deletion tests/image/test_image.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pytest
import numpy as np
from io import BytesIO
from PIL import Image
from nodetool.nodes.lib.numpy import ConvertToArray
Expand Down
2 changes: 1 addition & 1 deletion tests/image/test_image_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import pytest
from nodetool.workflows.processing_context import ProcessingContext
from nodetool.metadata.types import ImageRef, NPArray
from nodetool.metadata.types import ImageRef
from nodetool.nodes.lib.pillow.draw import Background, RenderText, GaussianNoise
import PIL.Image

Expand Down
2 changes: 1 addition & 1 deletion tests/image/test_image_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from io import BytesIO
from PIL import Image
from nodetool.workflows.processing_context import ProcessingContext
from nodetool.metadata.types import ImageRef, NPArray
from nodetool.metadata.types import ImageRef
from nodetool.nodes.lib.pillow.filter import (
Invert,
Solarize,
Expand Down
Loading