From 46a6ca62c4a3ebec7c48a766df0416e5af3f7044 Mon Sep 17 00:00:00 2001 From: Ashvin-KS Date: Sun, 24 May 2026 20:37:39 +0530 Subject: [PATCH 1/4] Add .editorconfig for consistent editor settings --- .editorconfig | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..2dbf9504 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false + +[*.yml] +indent_size = 2 + +[*.yaml] +indent_size = 2 + +[Makefile] +indent_style = tab From ccce20aaf0fde1ff6cdad085964ec54067448e87 Mon Sep 17 00:00:00 2001 From: Ashvin-KS Date: Sun, 24 May 2026 20:39:44 +0530 Subject: [PATCH 2/4] Fix bare except: clauses in 3 Python games --- games/Dots-Boxes-AI/Dots-Boxes-AI.py | 2 +- games/Flappy-Game/Flappy-Game.py | 2 +- games/Math-Quiz/Math-Quiz.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/games/Dots-Boxes-AI/Dots-Boxes-AI.py b/games/Dots-Boxes-AI/Dots-Boxes-AI.py index c2d71919..49503bb1 100644 --- a/games/Dots-Boxes-AI/Dots-Boxes-AI.py +++ b/games/Dots-Boxes-AI/Dots-Boxes-AI.py @@ -286,7 +286,7 @@ def ai_move(): print(YELLOW + "⚠️ Line already taken!" + RESET) continue vertical_lines[row][col] = True - except: + except (IndexError, ValueError): print(RED + "❌ Position out of range!" + RESET) continue diff --git a/games/Flappy-Game/Flappy-Game.py b/games/Flappy-Game/Flappy-Game.py index dea857a8..9ec6c7c9 100644 --- a/games/Flappy-Game/Flappy-Game.py +++ b/games/Flappy-Game/Flappy-Game.py @@ -51,7 +51,7 @@ def reset_game(): try: with open(highscore_path, "r") as file: high_score = int(file.read()) -except: +except (FileNotFoundError, ValueError): high_score = 0 def inside(point): diff --git a/games/Math-Quiz/Math-Quiz.py b/games/Math-Quiz/Math-Quiz.py index 0de5139f..e4eeb092 100644 --- a/games/Math-Quiz/Math-Quiz.py +++ b/games/Math-Quiz/Math-Quiz.py @@ -35,7 +35,7 @@ def play_sound(sound_type): winsound.Beep(300, 300) elif sound_type == 'game_over': winsound.Beep(200, 600) - except: + except RuntimeError: pass def load_scores(): @@ -43,7 +43,7 @@ def load_scores(): try: with open("math_quiz_scores.json", "r") as f: return json.load(f) - except: + except (FileNotFoundError, json.JSONDecodeError): pass return {"highest_score": 0, "longest_streak": 0} From 90fac6b2089ee9dc9906166a586e3defb0531454 Mon Sep 17 00:00:00 2001 From: Ashvin-KS Date: Sun, 24 May 2026 20:47:24 +0530 Subject: [PATCH 3/4] Fix CI: install dependencies before running tests in python-ci.yml --- .github/workflows/python-ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml index 9e6994cd..bca46eb3 100644 --- a/.github/workflows/python-ci.yml +++ b/.github/workflows/python-ci.yml @@ -22,6 +22,11 @@ jobs: with: python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-dev.txt + - name: Syntax check with py_compile run: | find . -name "*.py" -exec python -m py_compile {} + From 6fdf996be165c41e5d67f623adc9aca6407ae46b Mon Sep 17 00:00:00 2001 From: Ashvin-KS Date: Sun, 24 May 2026 20:48:58 +0530 Subject: [PATCH 4/4] Improve exception specificity per Copilot review --- games/Dots-Boxes-AI/Dots-Boxes-AI.py | 5 ++++- games/Flappy-Game/Flappy-Game.py | 2 +- games/Math-Quiz/Math-Quiz.py | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/games/Dots-Boxes-AI/Dots-Boxes-AI.py b/games/Dots-Boxes-AI/Dots-Boxes-AI.py index 49503bb1..abc2826e 100644 --- a/games/Dots-Boxes-AI/Dots-Boxes-AI.py +++ b/games/Dots-Boxes-AI/Dots-Boxes-AI.py @@ -286,9 +286,12 @@ def ai_move(): print(YELLOW + "⚠️ Line already taken!" + RESET) continue vertical_lines[row][col] = True - except (IndexError, ValueError): + except IndexError: print(RED + "❌ Position out of range!" + RESET) continue + except ValueError: + print(RED + "❌ Invalid input!" + RESET) + continue symbol = 'P' if current_player == 1 else 'A' got_box = check_boxes(symbol) diff --git a/games/Flappy-Game/Flappy-Game.py b/games/Flappy-Game/Flappy-Game.py index 9ec6c7c9..cb4fe969 100644 --- a/games/Flappy-Game/Flappy-Game.py +++ b/games/Flappy-Game/Flappy-Game.py @@ -51,7 +51,7 @@ def reset_game(): try: with open(highscore_path, "r") as file: high_score = int(file.read()) -except (FileNotFoundError, ValueError): +except (FileNotFoundError, ValueError, OSError): high_score = 0 def inside(point): diff --git a/games/Math-Quiz/Math-Quiz.py b/games/Math-Quiz/Math-Quiz.py index e4eeb092..a8faf804 100644 --- a/games/Math-Quiz/Math-Quiz.py +++ b/games/Math-Quiz/Math-Quiz.py @@ -35,7 +35,7 @@ def play_sound(sound_type): winsound.Beep(300, 300) elif sound_type == 'game_over': winsound.Beep(200, 600) - except RuntimeError: + except (RuntimeError, OSError): pass def load_scores(): @@ -43,7 +43,7 @@ def load_scores(): try: with open("math_quiz_scores.json", "r") as f: return json.load(f) - except (FileNotFoundError, json.JSONDecodeError): + except (FileNotFoundError, json.JSONDecodeError, OSError, UnicodeDecodeError): pass return {"highest_score": 0, "longest_streak": 0}