55
66import traceback
77from pathlib import Path
8+ from typing import cast
89
910import structlog
1011from PySide6 .QtCore import QObject , Qt , QThreadPool , Signal
@@ -61,8 +62,8 @@ def __init__(self, path: Path):
6162 self .path : Path = path
6263
6364 self .stack : list [PagedPanelState ] = []
64- self .json_lib : JsonLibrary = None
65- self .sql_lib : SqliteLibrary = None
65+ self .json_lib : JsonLibrary = None # pyright: ignore[reportAttributeAccessIssue]
66+ self .sql_lib : SqliteLibrary = None # pyright: ignore[reportAttributeAccessIssue]
6667 self .is_migration_initialized : bool = False
6768 self .discrepancies : list [str ] = []
6869
@@ -72,7 +73,7 @@ def __init__(self, path: Path):
7273 self .old_entry_count : int = 0
7374 self .old_tag_count : int = 0
7475 self .old_ext_count : int = 0
75- self .old_ext_type : bool = None
76+ self .old_ext_type : bool = None # pyright: ignore[reportAttributeAccessIssue]
7677
7778 self .field_parity : bool = False
7879 self .path_parity : bool = False
@@ -367,7 +368,7 @@ def migration_progress(self, skip_ui: bool = False):
367368 minimum = 0 ,
368369 maximum = 0 ,
369370 )
370- pb .setCancelButton (None )
371+ pb .setCancelButton (None ) # pyright: ignore[reportArgumentType]
371372 self .body_wrapper_01 .layout ().addWidget (pb )
372373
373374 try :
@@ -390,7 +391,7 @@ def migration_progress(self, skip_ui: bool = False):
390391 pb .setMinimum (1 ), # type: ignore
391392 pb .setValue (1 ), # type: ignore
392393 # Enable the finish button
393- self .stack [1 ].buttons [4 ].setDisabled (False ),
394+ cast ( QPushButtonWrapper , self .stack [1 ].buttons [4 ]) .setDisabled (False ),
394395 )
395396 )
396397 QThreadPool .globalInstance ().start (r )
@@ -474,7 +475,7 @@ def update_sql_value_ui(self, show_msg_box: bool = True):
474475 )
475476 self .update_sql_value (
476477 self .ext_type_row ,
477- self .sql_lib .prefs (LibraryPrefs .IS_EXCLUDE_LIST ),
478+ self .sql_lib .prefs (LibraryPrefs .IS_EXCLUDE_LIST ), # pyright: ignore[reportArgumentType]
478479 self .old_ext_type ,
479480 )
480481 logger .info ("Parity check complete!" )
@@ -636,18 +637,15 @@ def check_path_parity(self) -> bool:
636637
637638 def check_subtag_parity (self ) -> bool :
638639 """Check if all JSON parent tags match the new SQL parent tags."""
639- sql_parent_tags : set [int ] = None
640- json_parent_tags : set [int ] = None
641-
642640 with Session (self .sql_lib .engine ) as session :
643641 for tag in self .sql_lib .tags :
644642 tag_id = tag .id # Tag IDs start at 0
645- sql_parent_tags = set (
643+ sql_parent_tags : set [ int ] = set (
646644 session .scalars (select (TagParent .parent_id ).where (TagParent .child_id == tag .id ))
647645 )
648646
649647 # JSON tags allowed self-parenting; SQL tags no longer allow this.
650- json_parent_tags = set (self .json_lib .get_tag (tag_id ).subtag_ids )
648+ json_parent_tags : set [ int ] = set (self .json_lib .get_tag (tag_id ).subtag_ids )
651649 json_parent_tags .discard (tag_id )
652650
653651 logger .info (
@@ -677,16 +675,15 @@ def check_ext_type(self) -> bool:
677675
678676 def check_alias_parity (self ) -> bool :
679677 """Check if all JSON aliases match the new SQL aliases."""
680- sql_aliases : set [str ] = None
681- json_aliases : set [str ] = None
682-
683678 with Session (self .sql_lib .engine ) as session :
684679 for tag in self .sql_lib .tags :
685680 tag_id = tag .id # Tag IDs start at 0
686- sql_aliases = set (
681+ sql_aliases : set [ str ] = set (
687682 session .scalars (select (TagAlias .name ).where (TagAlias .tag_id == tag .id ))
688683 )
689- json_aliases = set ([x for x in self .json_lib .get_tag (tag_id ).aliases if x ])
684+ json_aliases : set [str ] = set (
685+ [x for x in self .json_lib .get_tag (tag_id ).aliases if x ]
686+ )
690687
691688 logger .info (
692689 "[Alias Parity]" ,
0 commit comments