Skip to content

Commit

Permalink
Fix type issues
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolCat467 committed Oct 13, 2024
1 parent 7ca6031 commit 24cc404
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/idlealign/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from re import Pattern


class AlignDialog(SearchDialogBase):
class AlignDialog(SearchDialogBase): # type: ignore[misc,unused-ignore]
"""Dialog for aligning by a pattern in text."""

__slots__ = (
Expand Down Expand Up @@ -100,7 +100,7 @@ def store_prefs(self) -> None:
self.search_params = utils.get_search_engine_params(self.engine)
utils.set_search_engine_params(self.engine, self.global_search_params)

def open( # type: ignore # "override"
def open( # type: ignore[override,unused-ignore]
self,
searchphrase: str | None = None,
insert_tags: str | list[str] | tuple[str, ...] = (),
Expand Down Expand Up @@ -173,7 +173,7 @@ def default_command(self, _event: Event[Any] | None = None) -> bool:

pattern = self.engine.getprog()
if not pattern:
return False # type: ignore # "unreachable"
return False # type: ignore[unreachable,unused-ignore]

space_wrap: bool = self.space_wrap_var.get()
align_side: bool = self.align_side_var.get()
Expand Down Expand Up @@ -229,14 +229,14 @@ def create_window(self) -> AlignDialog:
engine: searchengine.SearchEngine = searchengine.get(root)

if not hasattr(engine, "_aligndialog"):
engine._aligndialog = AlignDialog( # type: ignore[attr-defined]
engine._aligndialog = AlignDialog( # type: ignore[attr-defined,unused-ignore]
root,
engine,
self,
)
return cast(
AlignDialog,
engine._aligndialog, # type: ignore[attr-defined]
engine._aligndialog, # type: ignore[attr-defined,unused-ignore]
)

@utils.log_exceptions
Expand Down
4 changes: 2 additions & 2 deletions src/idlealign/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,13 @@ def wrapper(*args: PS.args, **kwargs: PS.kwargs) -> T:
"""Catch Exceptions, log them to log file, and re-raise."""
try:
return function(*args, **kwargs)
except Exception as exc:
except Exception:
if not LOGS_PATH.exists():
LOGS_PATH.mkdir(exist_ok=True)
log_file = LOGS_PATH / f"{TITLE}.log"
with log_file.open("a", encoding="utf-8") as fp:
format_time = time.strftime("[%Y-%m-%d %H:%M:%S] ")
exception_text = "".join(traceback.format_exception(exc))
exception_text = "".join(traceback.format_exc())
for line in exception_text.splitlines(keepends=True):
fp.write(f"{format_time}{line}")
raise
Expand Down

0 comments on commit 24cc404

Please sign in to comment.