Skip to content

Commit

Permalink
fix(main): typing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
One-Nose committed Aug 10, 2023
1 parent a81e07e commit bda1ddf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path
from shutil import copyfile, make_archive, rmtree
from sys import argv
from typing import Iterable, Sequence, TypedDict
from typing import Iterable, Sequence, TypedDict, cast

from PIL import Image
from tqdm import tqdm
Expand Down Expand Up @@ -67,15 +67,17 @@ def color_palette(texture: Path) -> Image.Image:
data.insert(index, tuple(sum(color_part) // 2 for color_part in zip(*pixels)))

result = Image.new('RGBA', (8, 1))
result.putdata(data)
result.putdata(data) # type: ignore
return result


def colors(texture: Path) -> set[tuple[int, int, int, int]]:
"""Gets all unique colors in a given texture"""

with Image.open(texture) as image:
data: Sequence[tuple[int, int, int, int]] = image.convert('RGBA').getdata()
data = cast(
Sequence[tuple[int, int, int, int]], image.convert('RGBA').getdata() # type: ignore
)
return set(color for color in data if color[3] > 0)


Expand Down

0 comments on commit bda1ddf

Please sign in to comment.