Compare commits

...

3 Commits

Author SHA1 Message Date
Jann Stute
32a9a04399 fix: tab order in build_tag modal (#1235) 2026-01-21 23:50:10 -08:00
Jann Stute
785959ec24 fix: pyright errors in blender_renderer.py (#1236) 2026-01-21 22:47:29 -08:00
Jann Stute
97c9d34186 fix: errors in DupeFilesRegistry (#1233) 2026-01-21 22:22:16 -08:00
6 changed files with 21 additions and 26 deletions

View File

@@ -7,6 +7,7 @@ import structlog
from tagstudio.core.library.alchemy.enums import BrowsingState
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import Entry
from tagstudio.core.utils.types import unwrap
logger = structlog.get_logger()
@@ -28,7 +29,7 @@ class DupeFilesRegistry:
A duplicate file is defined as an identical or near-identical file as determined
by a DupeGuru results file.
"""
library_dir = self.library.library_dir
library_dir = unwrap(self.library.library_dir)
if not isinstance(results_filepath, Path):
results_filepath = Path(results_filepath)
@@ -43,7 +44,7 @@ class DupeFilesRegistry:
files: list[Entry] = []
for element in group:
if element.tag == "file":
file_path = Path(element.attrib.get("path"))
file_path = Path(unwrap(element.attrib.get("path")))
try:
path_relative = file_path.relative_to(library_dir)
@@ -82,5 +83,5 @@ class DupeFilesRegistry:
for i, entries in enumerate(self.groups):
remove_ids = entries[1:]
logger.info("Removing entries group", ids=remove_ids)
self.library.remove_entries(remove_ids)
self.library.remove_entries([e.id for e in remove_ids])
yield i - 1 # The -1 waits for the next step to finish

View File

@@ -2,8 +2,6 @@
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
# pyright: reportExplicitAny=false
import os
import subprocess
import sys

View File

@@ -522,7 +522,7 @@ class BuildTagPanel(PanelWidget):
self.alias_names.clear()
last: QWidget = self.panel_save_button
last: QWidget | None = self.panel_save_button
for alias_id in self.alias_ids:
alias = self.lib.get_alias(self.tag.id, alias_id)
@@ -549,7 +549,8 @@ class BuildTagPanel(PanelWidget):
self.aliases_table.setCellWidget(row, 1, new_item)
self.aliases_table.setCellWidget(row, 0, remove_btn)
self.setTabOrder(last, self.aliases_table.cellWidget(row, 1))
if last is not None:
self.setTabOrder(last, self.aliases_table.cellWidget(row, 1))
self.setTabOrder(
self.aliases_table.cellWidget(row, 1), self.aliases_table.cellWidget(row, 0)
)
@@ -624,3 +625,4 @@ class BuildTagPanel(PanelWidget):
self.setTabOrder(unwrap(self.panel_save_button), self.aliases_table.cellWidget(0, 1))
self.name_field.selectAll()
self.name_field.setFocus()
self._set_aliases()

View File

@@ -790,25 +790,17 @@ class ThumbRenderer(QObject):
)
im: Image.Image | None = None
try:
blend_image = blend_thumb(str(filepath))
bg = Image.new("RGB", blend_image.size, color=bg_color)
bg.paste(blend_image, mask=blend_image.getchannel(3))
im = bg
except (
AttributeError,
UnidentifiedImageError,
TypeError,
) as e:
if str(e) == "expected string or buffer":
if (blend_image := blend_thumb(str(filepath))) is not None:
bg = Image.new("RGB", blend_image.size, color=bg_color)
bg.paste(blend_image, mask=blend_image.getchannel(3))
im = bg
else:
logger.info(
f"[ThumbRenderer][BLENDER][INFO] {filepath.name} "
f"Doesn't have an embedded thumbnail. ({type(e).__name__})"
"Doesn't have an embedded thumbnail."
)
else:
logger.error("Couldn't render thumbnail", filepath=filepath, error=type(e).__name__)
except Exception as e:
logger.error("Couldn't render thumbnail", filepath=filepath, error=type(e).__name__)
return im
@staticmethod

View File

@@ -32,7 +32,7 @@ from io import BufferedReader
from PIL import Image, ImageOps
def blend_extract_thumb(path):
def blend_extract_thumb(path) -> tuple[bytes | None, int, int]:
rend = b"REND"
test = b"TEST"
@@ -97,8 +97,10 @@ def blend_extract_thumb(path):
return image_buffer, x, y
def blend_thumb(file_in):
def blend_thumb(file_in) -> Image.Image | None:
buf, width, height = blend_extract_thumb(file_in)
if buf is None:
return None
image = Image.frombuffer(
"RGBA",
(width, height),

View File

@@ -383,7 +383,7 @@ class ThumbGridLayout(QLayout):
@override
def itemAt(self, index: int) -> QLayoutItem:
if index >= len(self._items):
return None
return None # pyright: ignore[reportReturnType]
return self._items[index]
@override