🎨 Auto format

This commit is contained in:
pre-commit-ci-lite[bot] 2025-12-09 09:53:58 +00:00 committed by GitHub
parent 19ca0aa2e9
commit 7a19e1d0aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 35 additions and 20 deletions

View File

@ -3,53 +3,68 @@
import ast
import sys
def check_syntax(filepath):
"""Check if Python file has valid syntax"""
try:
with open(filepath, 'r', encoding='utf-8') as f:
with open(filepath, encoding="utf-8") as f:
code = f.read()
ast.parse(code)
return True, "Syntax OK"
except SyntaxError as e:
return False, f"Syntax Error: {e}"
def check_no_shadowing(filepath):
"""Check that we fixed the variable shadowing issue"""
with open(filepath, 'r', encoding='utf-8') as f:
with open(filepath, encoding="utf-8") as f:
content = f.read()
# Check that inner_app exists (our fix)
if 'async def inner_app(scope: Scope, receive: Receive, send: Send)' in content:
inner_app_count = content.count('async def inner_app(scope: Scope, receive: Receive, send: Send)')
if "async def inner_app(scope: Scope, receive: Receive, send: Send)" in content:
inner_app_count = content.count(
"async def inner_app(scope: Scope, receive: Receive, send: Send)"
)
if inner_app_count >= 2: # Should be in both functions
return True, f"✓ Found {inner_app_count} instances of 'inner_app' (expected 2)"
return (
True,
f"✓ Found {inner_app_count} instances of 'inner_app' (expected 2)",
)
else:
return False, f"✗ Found only {inner_app_count} instances of 'inner_app'"
else:
return False, "'inner_app' not found - fix not applied"
def check_wrap_app_handling_exceptions(filepath):
"""Check that wrap_app_handling_exceptions uses inner_app not app"""
with open(filepath, 'r', encoding='utf-8') as f:
with open(filepath, encoding="utf-8") as f:
content = f.read()
# Check request_response function
lines = content.split('\n')
lines = content.split("\n")
found_request_response = False
found_correct_usage = False
for i, line in enumerate(lines):
if 'def request_response(' in line:
if "def request_response(" in line:
found_request_response = True
if found_request_response and 'await wrap_app_handling_exceptions(inner_app, request)' in line:
if (
found_request_response
and "await wrap_app_handling_exceptions(inner_app, request)" in line
):
found_correct_usage = True
break
if not found_correct_usage:
return False, "✗ wrap_app_handling_exceptions still uses 'app' instead of 'inner_app'"
return (
False,
"✗ wrap_app_handling_exceptions still uses 'app' instead of 'inner_app'",
)
return True, "✓ wrap_app_handling_exceptions correctly uses 'inner_app'"
if __name__ == "__main__":
filepath = "fastapi/routing.py"