mirror of
https://github.com/TagStudioDev/TagStudio.git
synced 2026-08-19 18:42:26 +02:00
chore: formatting pass
This commit is contained in:
@@ -57,7 +57,7 @@ class TagColorEnum(enum.IntEnum):
|
||||
OLIVE = 37
|
||||
|
||||
@staticmethod
|
||||
def get_color_from_str(color_name: str) -> "TagColorEnum":
|
||||
def get_color_from_str(color_name: str) -> TagColorEnum:
|
||||
for color in TagColorEnum:
|
||||
if color.name == color_name.upper().replace(" ", "_"):
|
||||
return color
|
||||
@@ -99,17 +99,15 @@ class BrowsingState:
|
||||
return Parser(self.query).parse()
|
||||
|
||||
@classmethod
|
||||
def show_all(cls) -> "BrowsingState":
|
||||
def show_all(cls) -> BrowsingState:
|
||||
return BrowsingState()
|
||||
|
||||
@classmethod
|
||||
def from_search_query(cls, search_query: str) -> "BrowsingState":
|
||||
def from_search_query(cls, search_query: str) -> BrowsingState:
|
||||
return cls(query=search_query)
|
||||
|
||||
@classmethod
|
||||
def from_tag_id(
|
||||
cls, tag_id: int | str, state: "BrowsingState | None" = None
|
||||
) -> "BrowsingState":
|
||||
def from_tag_id(cls, tag_id: int | str, state: BrowsingState | None = None) -> BrowsingState:
|
||||
"""Create and return a BrowsingState object given a tag ID.
|
||||
|
||||
Args:
|
||||
@@ -124,35 +122,35 @@ class BrowsingState:
|
||||
return cls(query=f"tag_id:{str(tag_id)}")
|
||||
|
||||
@classmethod
|
||||
def from_path(cls, path: Path | str) -> "BrowsingState":
|
||||
def from_path(cls, path: Path | str) -> BrowsingState:
|
||||
return cls(query=f'path:"{str(path).strip()}"')
|
||||
|
||||
@classmethod
|
||||
def from_mediatype(cls, mediatype: str) -> "BrowsingState":
|
||||
def from_mediatype(cls, mediatype: str) -> BrowsingState:
|
||||
return cls(query=f"mediatype:{mediatype}")
|
||||
|
||||
@classmethod
|
||||
def from_filetype(cls, filetype: str) -> "BrowsingState":
|
||||
def from_filetype(cls, filetype: str) -> BrowsingState:
|
||||
return cls(query=f"filetype:{filetype}")
|
||||
|
||||
@classmethod
|
||||
def from_tag_name(cls, tag_name: str) -> "BrowsingState":
|
||||
def from_tag_name(cls, tag_name: str) -> BrowsingState:
|
||||
return cls(query=f'tag:"{tag_name}"')
|
||||
|
||||
def with_page_index(self, index: int) -> "BrowsingState":
|
||||
def with_page_index(self, index: int) -> BrowsingState:
|
||||
return replace(self, page_index=index)
|
||||
|
||||
def with_sorting_mode(self, mode: SortingModeEnum) -> "BrowsingState":
|
||||
def with_sorting_mode(self, mode: SortingModeEnum) -> BrowsingState:
|
||||
seed = self.random_seed
|
||||
if mode == SortingModeEnum.RANDOM:
|
||||
seed = random.random()
|
||||
return replace(self, sorting_mode=mode, random_seed=seed)
|
||||
|
||||
def with_sorting_direction(self, ascending: bool) -> "BrowsingState":
|
||||
def with_sorting_direction(self, ascending: bool) -> BrowsingState:
|
||||
return replace(self, ascending=ascending)
|
||||
|
||||
def with_search_query(self, search_query: str) -> "BrowsingState":
|
||||
def with_search_query(self, search_query: str) -> BrowsingState:
|
||||
return replace(self, query=search_query)
|
||||
|
||||
def with_show_hidden_entries(self, show_hidden_entries: bool) -> "BrowsingState":
|
||||
def with_show_hidden_entries(self, show_hidden_entries: bool) -> BrowsingState:
|
||||
return replace(self, show_hidden_entries=show_hidden_entries)
|
||||
|
||||
@@ -41,7 +41,7 @@ class TagAlias(Base):
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
name: Mapped[str] = mapped_column(nullable=False)
|
||||
tag_id: Mapped[int] = mapped_column(ForeignKey("tags.id"))
|
||||
tag: Mapped["Tag"] = relationship(back_populates="aliases")
|
||||
tag: Mapped[Tag] = relationship(back_populates="aliases")
|
||||
|
||||
def __init__(self, name: str, tag_id: int | None = None):
|
||||
self.name = name
|
||||
@@ -97,14 +97,14 @@ class Tag(Base):
|
||||
is_hidden: Mapped[bool]
|
||||
icon: Mapped[str | None]
|
||||
aliases: Mapped[set[TagAlias]] = relationship(back_populates="tag")
|
||||
parent_tags: Mapped[set["Tag"]] = relationship(
|
||||
parent_tags: Mapped[set[Tag]] = relationship(
|
||||
secondary=TagParent.__tablename__,
|
||||
primaryjoin="Tag.id == TagParent.child_id",
|
||||
secondaryjoin="Tag.id == TagParent.parent_id",
|
||||
back_populates="parent_tags",
|
||||
)
|
||||
disambiguation_id: Mapped[int | None]
|
||||
category_exclusions: Mapped[set["Tag"]] = relationship(
|
||||
category_exclusions: Mapped[set[Tag]] = relationship(
|
||||
secondary=CategoryExclusion.__tablename__,
|
||||
primaryjoin="Tag.id == CategoryExclusion.tag_id",
|
||||
secondaryjoin="Tag.id == CategoryExclusion.category_id",
|
||||
@@ -140,14 +140,14 @@ class Tag(Base):
|
||||
id: int | None = None,
|
||||
shorthand: str | None = None,
|
||||
aliases: set[TagAlias] | None = None,
|
||||
parent_tags: set["Tag"] | None = None,
|
||||
parent_tags: set[Tag] | None = None,
|
||||
icon: str | None = None,
|
||||
color_namespace: str | None = None,
|
||||
color_slug: str | None = None,
|
||||
disambiguation_id: int | None = None,
|
||||
is_category: bool = False,
|
||||
is_hidden: bool = False,
|
||||
category_exclusions: set["Tag"] | None = None,
|
||||
category_exclusions: set[Tag] | None = None,
|
||||
):
|
||||
self.name = name
|
||||
self.aliases = aliases or set()
|
||||
@@ -181,16 +181,16 @@ class Tag(Base):
|
||||
return False
|
||||
return self.id == value.id
|
||||
|
||||
def __lt__(self, other: "Tag") -> bool:
|
||||
def __lt__(self, other: Tag) -> bool:
|
||||
return self.name < other.name
|
||||
|
||||
def __le__(self, other: "Tag") -> bool:
|
||||
def __le__(self, other: Tag) -> bool:
|
||||
return self.name <= other.name
|
||||
|
||||
def __gt__(self, other: "Tag") -> bool:
|
||||
def __gt__(self, other: Tag) -> bool:
|
||||
return self.name > other.name
|
||||
|
||||
def __ge__(self, other: "Tag") -> bool:
|
||||
def __ge__(self, other: Tag) -> bool:
|
||||
return self.name >= other.name
|
||||
|
||||
|
||||
|
||||
@@ -861,7 +861,7 @@ class Library:
|
||||
self.files_not_in_library,
|
||||
key=lambda t: -(self.library_dir / t).stat().st_ctime,
|
||||
)
|
||||
except (FileExistsError, FileNotFoundError):
|
||||
except FileExistsError, FileNotFoundError:
|
||||
print(
|
||||
"[LIBRARY] [ERROR] Couldn't sort files, some were moved during the scanning/sorting process."
|
||||
)
|
||||
|
||||
@@ -16,7 +16,7 @@ class ConstraintType(Enum):
|
||||
Special = 5
|
||||
|
||||
@staticmethod
|
||||
def from_string(text: str) -> "ConstraintType | None":
|
||||
def from_string(text: str) -> ConstraintType | None:
|
||||
return {
|
||||
"tag": ConstraintType.Tag,
|
||||
"tag_id": ConstraintType.TagID,
|
||||
@@ -28,7 +28,7 @@ class ConstraintType(Enum):
|
||||
|
||||
|
||||
class AST:
|
||||
parent: "AST | None" = None
|
||||
parent: AST | None = None
|
||||
|
||||
@override
|
||||
def __str__(self):
|
||||
@@ -65,9 +65,9 @@ class ORList(AST):
|
||||
class Constraint(AST):
|
||||
type: ConstraintType
|
||||
value: str
|
||||
properties: list["Property"]
|
||||
properties: list[Property]
|
||||
|
||||
def __init__(self, type: ConstraintType, value: str, properties: list["Property"]) -> None:
|
||||
def __init__(self, type: ConstraintType, value: str, properties: list[Property]) -> None:
|
||||
super().__init__()
|
||||
for prop in properties:
|
||||
prop.parent = self
|
||||
|
||||
@@ -39,11 +39,11 @@ class Token:
|
||||
self.end = end
|
||||
|
||||
@staticmethod
|
||||
def from_type(type: TokenType, pos: int) -> "Token":
|
||||
def from_type(type: TokenType, pos: int) -> Token:
|
||||
return Token(type, None, pos, pos)
|
||||
|
||||
@staticmethod
|
||||
def EOF(pos: int) -> "Token": # noqa: N802
|
||||
def EOF(pos: int) -> Token: # noqa: N802
|
||||
return Token.from_type(TokenType.EOF, pos)
|
||||
|
||||
@override
|
||||
|
||||
@@ -58,5 +58,5 @@ def format_duration(duration: int | float) -> str:
|
||||
hours, seconds = divmod(seconds, 3600)
|
||||
minutes, seconds = divmod(seconds, 60)
|
||||
return f"{hours}:{minutes:02}:{seconds:02}" if hours else f"{minutes}:{seconds:02}"
|
||||
except (OverflowError, ValueError):
|
||||
except OverflowError, ValueError:
|
||||
return "-:--"
|
||||
|
||||
@@ -86,7 +86,7 @@ class Translator:
|
||||
def __format(self, text: str, **kwargs: ...) -> str:
|
||||
try:
|
||||
return text.format(**kwargs)
|
||||
except (KeyError, ValueError):
|
||||
except KeyError, ValueError:
|
||||
logger.error(
|
||||
"[Translations] Error while formatting translation.",
|
||||
text=text,
|
||||
|
||||
@@ -52,7 +52,7 @@ class TarFile:
|
||||
def read(self, name: str) -> bytes:
|
||||
return unwrap(self.tar.extractfile(name)).read()
|
||||
|
||||
def __enter__(self) -> "TarFile":
|
||||
def __enter__(self) -> TarFile:
|
||||
self.tar = tarfile.open(name=self.filepath, mode=self.mode).__enter__()
|
||||
return self
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ class AppSettings(BaseModel):
|
||||
loaded_from: Path = Field(default=DEFAULT_GLOBAL_SETTINGS_PATH, exclude=True)
|
||||
|
||||
@staticmethod
|
||||
def read_settings(path: Path = DEFAULT_GLOBAL_SETTINGS_PATH) -> "AppSettings":
|
||||
def read_settings(path: Path = DEFAULT_GLOBAL_SETTINGS_PATH) -> AppSettings:
|
||||
if path.exists():
|
||||
with open(path) as file:
|
||||
filecontents = file.read()
|
||||
|
||||
@@ -24,7 +24,7 @@ logger = structlog.get_logger(__name__)
|
||||
|
||||
# TODO: Use newer MVC style guidelines
|
||||
class FixIgnoredEntriesModal(FixIgnoredEntriesModalView):
|
||||
def __init__(self, library: "Library", driver: "QtDriver"):
|
||||
def __init__(self, library: Library, driver: QtDriver):
|
||||
super().__init__(library, driver)
|
||||
self.tracker = IgnoredRegistry(self.lib)
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class _ItemMode(IntEnum):
|
||||
|
||||
|
||||
class Inspector(QWidget):
|
||||
def __init__(self, driver: "QtDriver") -> None:
|
||||
def __init__(self, driver: QtDriver) -> None:
|
||||
super().__init__()
|
||||
self._driver = driver
|
||||
self._lib = self._driver.lib
|
||||
|
||||
@@ -33,7 +33,7 @@ logger = structlog.get_logger(__name__)
|
||||
|
||||
# TODO: Use newer MVC style guidelines
|
||||
class LibraryInfoWindow(LibraryInfoWindowView):
|
||||
def __init__(self, library: "Library", driver: "QtDriver"):
|
||||
def __init__(self, library: Library, driver: QtDriver):
|
||||
super().__init__(library, driver)
|
||||
|
||||
# Statistics Buttons
|
||||
|
||||
@@ -458,7 +458,7 @@ class MainWindow(QMainWindow):
|
||||
(Translations["home.thumbnail_size.mini"], 76),
|
||||
]
|
||||
|
||||
def __init__(self, driver: "QtDriver", parent: QWidget | None = None) -> None:
|
||||
def __init__(self, driver: QtDriver, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent)
|
||||
self.rm = ResourceManager()
|
||||
|
||||
@@ -529,7 +529,7 @@ class MainWindow(QMainWindow):
|
||||
|
||||
# endregion
|
||||
|
||||
def setup_central_widget(self, driver: "QtDriver"):
|
||||
def setup_central_widget(self, driver: QtDriver):
|
||||
self.central_widget = QWidget(self)
|
||||
self.central_widget.setObjectName("central_widget")
|
||||
self.central_layout = QGridLayout(self.central_widget)
|
||||
@@ -651,7 +651,7 @@ class MainWindow(QMainWindow):
|
||||
|
||||
self.central_layout.addLayout(self.extra_input_layout, 5, 0, 1, 1)
|
||||
|
||||
def setup_content(self, driver: "QtDriver"):
|
||||
def setup_content(self, driver: QtDriver):
|
||||
self.content_layout = QHBoxLayout()
|
||||
self.content_layout.setObjectName("content_layout")
|
||||
|
||||
@@ -667,7 +667,7 @@ class MainWindow(QMainWindow):
|
||||
|
||||
self.central_layout.addLayout(self.content_layout, 10, 0, 1, 1)
|
||||
|
||||
def setup_entry_list(self, driver: "QtDriver"):
|
||||
def setup_entry_list(self, driver: QtDriver):
|
||||
self.entry_list_container = QWidget()
|
||||
self.entry_list_layout = QVBoxLayout(self.entry_list_container)
|
||||
self.entry_list_layout.setSpacing(0)
|
||||
@@ -700,7 +700,7 @@ class MainWindow(QMainWindow):
|
||||
self.entry_list_layout.addWidget(self.pagination)
|
||||
self.content_splitter.addWidget(self.entry_list_container)
|
||||
|
||||
def setup_preview_panel(self, driver: "QtDriver"):
|
||||
def setup_preview_panel(self, driver: QtDriver):
|
||||
self.preview_panel = Inspector(driver)
|
||||
self.content_splitter.addWidget(self.preview_panel)
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ if typing.TYPE_CHECKING:
|
||||
class MergeDuplicateEntriesProgress(QObject):
|
||||
done = Signal()
|
||||
|
||||
def __init__(self, library: "Library", driver: "QtDriver"):
|
||||
def __init__(self, library: Library, driver: QtDriver):
|
||||
super().__init__()
|
||||
self.lib = library
|
||||
self.driver = driver
|
||||
|
||||
@@ -33,7 +33,7 @@ Image.MAX_IMAGE_PIXELS = None
|
||||
|
||||
# TODO: Use newer MVC style guidelines
|
||||
class PreviewThumb(PreviewThumbView):
|
||||
def __init__(self, library: Library, driver: "QtDriver"):
|
||||
def __init__(self, library: Library, driver: QtDriver):
|
||||
super().__init__(library, driver)
|
||||
|
||||
self.__driver: QtDriver = driver
|
||||
|
||||
@@ -78,7 +78,7 @@ class SearchPanel[T](ModalContent):
|
||||
self.setMinimumSize(300, 400)
|
||||
self.connect_callbacks(self)
|
||||
|
||||
def connect_callbacks(self, controller: "SearchPanel[Any]") -> None: # pyright: ignore[reportExplicitAny]
|
||||
def connect_callbacks(self, controller: SearchPanel[Any]) -> None: # pyright: ignore[reportExplicitAny]
|
||||
self.layout().limit_combobox.currentIndexChanged.connect(controller.on_limit_changed)
|
||||
self.layout().search_field.textChanged.connect(controller.on_search_query_changed)
|
||||
self.layout().search_field.returnPressed.connect(
|
||||
|
||||
@@ -28,7 +28,7 @@ class TagBoxWidget(TagBoxWidgetView):
|
||||
|
||||
__entries: list[int] = []
|
||||
|
||||
def __init__(self, title: str, driver: "QtDriver"):
|
||||
def __init__(self, title: str, driver: QtDriver):
|
||||
super().__init__(title, driver)
|
||||
self.__driver = driver
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ class ColorBoxWidget(FieldWidget):
|
||||
def __init__(
|
||||
self,
|
||||
group: str,
|
||||
colors: list["TagColorGroup"],
|
||||
library: "Library",
|
||||
colors: list[TagColorGroup],
|
||||
library: Library,
|
||||
) -> None:
|
||||
self.namespace = group
|
||||
self.colors: list[TagColorGroup] = colors
|
||||
|
||||
@@ -41,7 +41,7 @@ def qdtf2dtf(dtf: str) -> str:
|
||||
|
||||
# TODO: Split to use MVC guidelines.
|
||||
class DatetimePicker(ModalContent):
|
||||
def __init__(self, driver: "QtDriver", name: str, datetime: dt | str):
|
||||
def __init__(self, driver: QtDriver, name: str, datetime: dt | str):
|
||||
super().__init__()
|
||||
self.setMinimumSize(300, 60)
|
||||
self.root_layout = QVBoxLayout(self)
|
||||
|
||||
@@ -34,7 +34,7 @@ class DuplicateChoice(enum.StrEnum):
|
||||
class DropImportModal(QWidget):
|
||||
DUPE_NAME_LIMT: int = 5
|
||||
|
||||
def __init__(self, driver: "QtDriver"):
|
||||
def __init__(self, driver: QtDriver):
|
||||
super().__init__()
|
||||
|
||||
self.driver: QtDriver = driver
|
||||
|
||||
@@ -50,7 +50,7 @@ class FieldContainers(QWidget):
|
||||
|
||||
on_tags_update = Signal()
|
||||
|
||||
def __init__(self, library: Library, driver: "QtDriver") -> None:
|
||||
def __init__(self, library: Library, driver: QtDriver) -> None:
|
||||
super().__init__()
|
||||
|
||||
self.lib = library
|
||||
@@ -321,7 +321,7 @@ class FieldContainers(QWidget):
|
||||
text = self.driver.settings.format_datetime(
|
||||
DatetimePicker.string2dt(field.value)
|
||||
)
|
||||
except (ValueError, AssertionError):
|
||||
except ValueError, AssertionError:
|
||||
text = str(field.value)
|
||||
else:
|
||||
text = f"<i>{Translations['field.mixed_data']}</i>"
|
||||
|
||||
@@ -136,7 +136,7 @@ class FieldContainer(QWidget):
|
||||
if callback:
|
||||
self.remove_button.clicked.connect(callback)
|
||||
|
||||
def set_inner_widget(self, widget: "FieldWidget") -> None:
|
||||
def set_inner_widget(self, widget: FieldWidget) -> None:
|
||||
if self.field_layout.itemAt(0):
|
||||
old: QWidget = self.field_layout.itemAt(0).widget()
|
||||
self.field_layout.removeWidget(old)
|
||||
|
||||
@@ -42,7 +42,7 @@ class FileAttributeData:
|
||||
|
||||
# TODO: Split to use MVC guidelines.
|
||||
class FileAttributes(QWidget):
|
||||
def __init__(self, library: Library, driver: "QtDriver"):
|
||||
def __init__(self, library: Library, driver: QtDriver):
|
||||
super().__init__()
|
||||
root_layout = QVBoxLayout(self)
|
||||
root_layout.setContentsMargins(0, 0, 0, 0)
|
||||
|
||||
@@ -28,7 +28,7 @@ if TYPE_CHECKING:
|
||||
|
||||
# TODO: Split to use MVC guidelines.
|
||||
class FixDupeFilesModal(QWidget):
|
||||
def __init__(self, library: "Library", driver: "QtDriver"):
|
||||
def __init__(self, library: Library, driver: QtDriver):
|
||||
super().__init__()
|
||||
self.lib = library
|
||||
self.driver = driver
|
||||
|
||||
@@ -24,7 +24,7 @@ if TYPE_CHECKING:
|
||||
|
||||
# TODO: Split to use MVC guidelines.
|
||||
class FixUnlinkedEntriesModal(QWidget):
|
||||
def __init__(self, library: "Library", driver: "QtDriver"):
|
||||
def __init__(self, library: Library, driver: QtDriver):
|
||||
super().__init__()
|
||||
self.lib = library
|
||||
self.driver = driver
|
||||
|
||||
@@ -6,6 +6,7 @@ import math
|
||||
from collections.abc import Sequence
|
||||
from dataclasses import dataclass, field
|
||||
from typing import TYPE_CHECKING, override
|
||||
from warnings import deprecated
|
||||
|
||||
import structlog
|
||||
from PySide6 import QtCore, QtGui
|
||||
@@ -19,7 +20,6 @@ from PySide6.QtWidgets import (
|
||||
QVBoxLayout,
|
||||
QWidget,
|
||||
)
|
||||
from typing_extensions import deprecated
|
||||
|
||||
from tagstudio.core.constants import TAG_ARCHIVED, TAG_FAVORITE
|
||||
from tagstudio.core.library.alchemy.enums import TagColorEnum
|
||||
@@ -39,7 +39,7 @@ logger = structlog.get_logger(__name__)
|
||||
|
||||
@dataclass
|
||||
class BranchData:
|
||||
dirs: dict[str, "BranchData"] = field(default_factory=dict)
|
||||
dirs: dict[str, BranchData] = field(default_factory=dict)
|
||||
files: list[str] = field(default_factory=list)
|
||||
tag: Tag | None = None
|
||||
|
||||
@@ -165,7 +165,7 @@ def generate_preview_data(library: Library) -> BranchData:
|
||||
|
||||
|
||||
class FoldersToTagsModal(QWidget):
|
||||
def __init__(self, library: "Library", driver: "QtDriver"):
|
||||
def __init__(self, library: Library, driver: QtDriver):
|
||||
super().__init__()
|
||||
self.library = library
|
||||
self.driver = driver
|
||||
|
||||
@@ -96,7 +96,7 @@ class ItemThumb(FlowWidget):
|
||||
self,
|
||||
mode: ItemType | None,
|
||||
library: Library,
|
||||
driver: "QtDriver",
|
||||
driver: QtDriver,
|
||||
thumb_size: tuple[int, int],
|
||||
show_filename_label: bool = False,
|
||||
):
|
||||
@@ -440,7 +440,7 @@ class ItemThumb(FlowWidget):
|
||||
self.thumb_button.setMinimumSize(size)
|
||||
self.thumb_button.setMaximumSize(size)
|
||||
|
||||
def set_item(self, entry: "Entry"):
|
||||
def set_item(self, entry: Entry):
|
||||
self.set_item_id(entry.id)
|
||||
path = unwrap(self.lib.library_dir) / entry.path
|
||||
self.set_item_path(path)
|
||||
|
||||
@@ -29,7 +29,7 @@ class LandingWidget(QWidget):
|
||||
mono_logo: Image.Image = rm.ts_logo_text_mono
|
||||
color_logo: Image.Image = rm.ts_logo_text_color
|
||||
|
||||
def __init__(self, driver: "QtDriver", pixel_ratio: float):
|
||||
def __init__(self, driver: QtDriver, pixel_ratio: float):
|
||||
super().__init__()
|
||||
self.driver = driver
|
||||
self.logo_label: ClickableLabel = ClickableLabel()
|
||||
|
||||
@@ -53,9 +53,9 @@ class MediaPlayer(QGraphicsView):
|
||||
Gives a basic control set to manage media playback.
|
||||
"""
|
||||
|
||||
video_preview: "VideoPreview | None" = None
|
||||
video_preview: VideoPreview | None = None
|
||||
|
||||
def __init__(self, driver: "QtDriver") -> None:
|
||||
def __init__(self, driver: QtDriver) -> None:
|
||||
super().__init__()
|
||||
self.driver = driver
|
||||
self.play_icon = QPixmap.fromImage(
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import traceback
|
||||
from pathlib import Path
|
||||
from typing import cast
|
||||
from warnings import deprecated
|
||||
|
||||
import structlog
|
||||
import wcmatch.fnmatch as fnmatch
|
||||
@@ -23,7 +24,6 @@ from PySide6.QtWidgets import (
|
||||
)
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session
|
||||
from typing_extensions import deprecated
|
||||
|
||||
from tagstudio.core.constants import (
|
||||
IGNORE_NAME,
|
||||
|
||||
@@ -22,7 +22,7 @@ if typing.TYPE_CHECKING:
|
||||
class MirrorEntriesModal(QWidget):
|
||||
done = Signal()
|
||||
|
||||
def __init__(self, driver: "QtDriver", tracker: DupeFilesRegistry):
|
||||
def __init__(self, driver: QtDriver, tracker: DupeFilesRegistry):
|
||||
super().__init__()
|
||||
self.driver = driver
|
||||
self.setWindowTitle(Translations["entries.mirror.window_title"])
|
||||
|
||||
@@ -22,7 +22,7 @@ if TYPE_CHECKING:
|
||||
class RemoveIgnoredModal(QWidget):
|
||||
done = Signal()
|
||||
|
||||
def __init__(self, driver: "QtDriver", tracker: IgnoredRegistry):
|
||||
def __init__(self, driver: QtDriver, tracker: IgnoredRegistry):
|
||||
super().__init__()
|
||||
self.driver = driver
|
||||
self.tracker = tracker
|
||||
|
||||
@@ -22,7 +22,7 @@ if TYPE_CHECKING:
|
||||
class RemoveUnlinkedEntriesModal(QWidget):
|
||||
done = Signal()
|
||||
|
||||
def __init__(self, driver: "QtDriver", tracker: UnlinkedRegistry):
|
||||
def __init__(self, driver: QtDriver, tracker: UnlinkedRegistry):
|
||||
super().__init__()
|
||||
self.driver = driver
|
||||
self.tracker = tracker
|
||||
|
||||
@@ -41,7 +41,7 @@ logger = structlog.get_logger(__name__)
|
||||
|
||||
# TODO: Split to use MVC guidelines.
|
||||
class SettingsPanel(ModalContent):
|
||||
driver: "QtDriver"
|
||||
driver: QtDriver
|
||||
|
||||
filepath_option_map: dict[ShowFilepathOption, str] = {
|
||||
ShowFilepathOption.SHOW_FULL_PATHS: Translations["settings.filepath.option.full"],
|
||||
@@ -88,7 +88,7 @@ class SettingsPanel(ModalContent):
|
||||
"%Y.%m.%d": "2024.08.21",
|
||||
}
|
||||
|
||||
def __init__(self, driver: "QtDriver"):
|
||||
def __init__(self, driver: QtDriver):
|
||||
super().__init__()
|
||||
# set these "constants" because language will be loaded from config shortly after startup
|
||||
# and we want to use the current language for the dropdowns
|
||||
@@ -400,7 +400,7 @@ class SettingsPanel(ModalContent):
|
||||
"splash": self.splash_combobox.currentData(),
|
||||
}
|
||||
|
||||
def update_settings(self, driver: "QtDriver"):
|
||||
def update_settings(self, driver: QtDriver):
|
||||
settings = self.get_settings()
|
||||
|
||||
driver.settings.language = settings["language"]
|
||||
@@ -440,7 +440,7 @@ class SettingsPanel(ModalContent):
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def build_modal(cls, driver: "QtDriver") -> Modal:
|
||||
def build_modal(cls, driver: QtDriver) -> Modal:
|
||||
settings_panel = cls(driver)
|
||||
|
||||
modal = Modal(
|
||||
|
||||
@@ -41,7 +41,7 @@ class TagColorLabel(QWidget):
|
||||
color: TagColorGroup | None,
|
||||
has_edit: bool,
|
||||
has_remove: bool,
|
||||
library: "Library | None" = None,
|
||||
library: Library | None = None,
|
||||
) -> None:
|
||||
super().__init__()
|
||||
self.color = color
|
||||
|
||||
@@ -42,7 +42,7 @@ class TagColorManager(QWidget):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
driver: "QtDriver",
|
||||
driver: QtDriver,
|
||||
):
|
||||
super().__init__()
|
||||
self.driver = driver
|
||||
|
||||
@@ -32,7 +32,7 @@ class TagColorPreview(QWidget):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
library: "Library",
|
||||
library: Library,
|
||||
tag_color_group: TagColorGroup | None,
|
||||
) -> None:
|
||||
super().__init__()
|
||||
|
||||
@@ -111,7 +111,7 @@ class TagWidget(QWidget):
|
||||
tag: Tag | None
|
||||
|
||||
def __init__(
|
||||
self, tag: Tag | None, has_edit: bool, has_remove: bool, library: "Library | None" = None
|
||||
self, tag: Tag | None, has_edit: bool, has_remove: bool, library: Library | None = None
|
||||
) -> None:
|
||||
super().__init__()
|
||||
self.tag = tag
|
||||
|
||||
@@ -20,7 +20,7 @@ class ResourceManager:
|
||||
|
||||
_map: dict[str, dict[str, str]] = {}
|
||||
_cache: dict[str, bytes | str | Image.Image | QPixmap] = {}
|
||||
_instance: "ResourceManager | None" = None
|
||||
_instance: ResourceManager | None = None
|
||||
|
||||
def __new__(cls):
|
||||
if ResourceManager._instance is None:
|
||||
|
||||
@@ -18,7 +18,7 @@ if TYPE_CHECKING:
|
||||
|
||||
# TODO: Use newer MVC style guidelines
|
||||
class FixIgnoredEntriesModalView(QWidget):
|
||||
def __init__(self, library: "Library", driver: "QtDriver"):
|
||||
def __init__(self, library: Library, driver: QtDriver):
|
||||
super().__init__()
|
||||
self.lib = library
|
||||
self.driver = driver
|
||||
|
||||
@@ -28,7 +28,7 @@ logger = structlog.get_logger(__name__)
|
||||
|
||||
|
||||
class InspectorView(QVBoxLayout):
|
||||
def __init__(self, driver: "QtDriver", pixel_ratio: float) -> None:
|
||||
def __init__(self, driver: QtDriver, pixel_ratio: float) -> None:
|
||||
super().__init__()
|
||||
self.setContentsMargins(0, 0, 0, 0)
|
||||
self.setSpacing(6)
|
||||
|
||||
@@ -27,7 +27,7 @@ class ThumbGridLayout(QLayout):
|
||||
# Id of first visible entry
|
||||
visible_changed = Signal(int)
|
||||
|
||||
def __init__(self, driver: "QtDriver", scroll_area: QScrollArea) -> None:
|
||||
def __init__(self, driver: QtDriver, scroll_area: QScrollArea) -> None:
|
||||
super().__init__(None)
|
||||
self.driver: QtDriver = driver
|
||||
self.scroll_area: QScrollArea = scroll_area
|
||||
|
||||
@@ -34,7 +34,7 @@ if TYPE_CHECKING:
|
||||
|
||||
# TODO: Use newer MVC style guidelines
|
||||
class LibraryInfoWindowView(QWidget):
|
||||
def __init__(self, library: "Library", driver: "QtDriver"):
|
||||
def __init__(self, library: Library, driver: QtDriver):
|
||||
super().__init__()
|
||||
self.lib = library
|
||||
self.driver = driver
|
||||
|
||||
@@ -44,7 +44,7 @@ class PreviewThumbView(QWidget):
|
||||
__should_render_on_resize: bool
|
||||
__rendered_res: tuple[int, int]
|
||||
|
||||
def __init__(self, library: Library, driver: "QtDriver") -> None:
|
||||
def __init__(self, library: Library, driver: QtDriver) -> None:
|
||||
super().__init__()
|
||||
self._driver = driver
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ logger = structlog.get_logger(__name__)
|
||||
class TagBoxWidgetView(FieldWidget):
|
||||
__lib: Library
|
||||
|
||||
def __init__(self, title: str, driver: "QtDriver") -> None:
|
||||
def __init__(self, title: str, driver: QtDriver) -> None:
|
||||
super().__init__(title)
|
||||
self.__lib = driver.lib
|
||||
|
||||
|
||||
Reference in New Issue
Block a user