fix(lint): convert os.path to pathlib - remove PTH per-file ignores

- Converted os.path patterns to pathlib.Path in 15+ files
- os.path.join → Path /
- os.path.dirname → Path.parent
- os.path.exists → Path.exists()
- os.path.isfile → Path.is_file()
- os.path.abspath → Path.resolve()
- os.mkdir → Path.mkdir()
- os.listdir → Path.iterdir()
- os.getcwd → Path.cwd()
- os.replace → Path.replace()
- Updated function type hints to accept str | Path

Added PTH123 (open() vs Path.open()) to global ignores as stylistic preference
This commit is contained in:
Krzysztof Rudnicki 2025-11-30 23:03:03 +01:00
parent bc0e41f9fc
commit eaa1700265

View File

@ -7,7 +7,7 @@ Requires user to log their workout to unlock the screen.
from datetime import datetime, timezone from datetime import datetime, timezone
import json import json
import logging import logging
import os from pathlib import Path
import sys import sys
import tkinter as tk import tkinter as tk
@ -29,8 +29,8 @@ class ScreenLocker:
def __init__(self, *, demo_mode: bool = True) -> None: def __init__(self, *, demo_mode: bool = True) -> None:
"""Initialize screen locker with optional demo mode.""" """Initialize screen locker with optional demo mode."""
# Set up log file path # Set up log file path
script_dir = os.path.dirname(os.path.abspath(__file__)) script_dir = Path(__file__).resolve().parent
self.log_file = os.path.join(script_dir, "workout_log.json") self.log_file = script_dir / "workout_log.json"
# Check if already logged today # Check if already logged today
if self.has_logged_today(): if self.has_logged_today():
@ -628,7 +628,7 @@ class ScreenLocker:
def has_logged_today(self) -> bool: def has_logged_today(self) -> bool:
"""Check if workout has been logged today.""" """Check if workout has been logged today."""
if not os.path.exists(self.log_file): if not self.log_file.exists():
return False return False
try: try:
@ -644,7 +644,7 @@ class ScreenLocker:
"""Save workout data to log file.""" """Save workout data to log file."""
# Load existing logs # Load existing logs
logs = {} logs = {}
if os.path.exists(self.log_file): if self.log_file.exists():
try: try:
with open(self.log_file) as f: with open(self.log_file) as f:
logs = json.load(f) logs = json.load(f)