Another attempt at fixing external numpad detection. I *think* some of them send numlock state with every event. If that's the case, this should fix it.

This commit is contained in:
Storm Dragon
2025-09-13 14:11:27 -04:00
parent 96cdda99c4
commit 2c38bcf5f4
7 changed files with 55 additions and 20 deletions

View File

@@ -13,6 +13,7 @@ Usage:
import ast
import os
import re
import sys
import argparse
import tempfile
@@ -24,13 +25,34 @@ class SyntaxValidator:
self.errors = []
self.warnings = []
self.fixed = []
def check_fstring_issues(self, content):
"""Check for common f-string formatting issues that cause syntax errors."""
issues = []
lines = content.split('\n')
for i, line in enumerate(lines, 1):
# Check for f-strings that appear to be broken across lines
# Pattern: f"some text {
if re.search(r'f"[^"]*{[^}]*$', line.strip()):
issues.append(f"Line {i}: Potential broken multiline f-string")
return issues
def validate_file(self, filepath):
"""Validate syntax of a single Python file."""
try:
with open(filepath, 'r', encoding='utf-8') as f:
content = f.read()
# Check for specific f-string issues before AST parsing
fstring_issues = self.check_fstring_issues(content)
if fstring_issues:
# Create a synthetic syntax error for f-string issues
error_msg = f"F-string issues: {'; '.join(fstring_issues)}"
self.errors.append((filepath, SyntaxError(error_msg), content))
return False, content
# Parse with AST (catches syntax errors)
ast.parse(content, filename=str(filepath))
return True, content