From eaa17002657c9951d91c09b2b53f8feee14f8d9e Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Sun, 30 Nov 2025 23:03:03 +0100 Subject: [PATCH] fix(lint): convert os.path to pathlib - remove PTH per-file ignores MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- screen_locker/screen_lock.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/screen_locker/screen_lock.py b/screen_locker/screen_lock.py index 9d3be03..235b718 100755 --- a/screen_locker/screen_lock.py +++ b/screen_locker/screen_lock.py @@ -7,7 +7,7 @@ Requires user to log their workout to unlock the screen. from datetime import datetime, timezone import json import logging -import os +from pathlib import Path import sys import tkinter as tk @@ -29,8 +29,8 @@ class ScreenLocker: def __init__(self, *, demo_mode: bool = True) -> None: """Initialize screen locker with optional demo mode.""" # Set up log file path - script_dir = os.path.dirname(os.path.abspath(__file__)) - self.log_file = os.path.join(script_dir, "workout_log.json") + script_dir = Path(__file__).resolve().parent + self.log_file = script_dir / "workout_log.json" # Check if already logged today if self.has_logged_today(): @@ -628,7 +628,7 @@ class ScreenLocker: def has_logged_today(self) -> bool: """Check if workout has been logged today.""" - if not os.path.exists(self.log_file): + if not self.log_file.exists(): return False try: @@ -644,7 +644,7 @@ class ScreenLocker: """Save workout data to log file.""" # Load existing logs logs = {} - if os.path.exists(self.log_file): + if self.log_file.exists(): try: with open(self.log_file) as f: logs = json.load(f)