Some checks failed
API Endpoint Tests / test-api-endpoints (push) Successful in 19s
Blockchain Synchronization Verification / sync-verification (push) Successful in 8s
Cross-Chain Functionality Tests / test-cross-chain-sync (push) Failing after 8s
Cross-Chain Functionality Tests / test-cross-chain-transactions (push) Successful in 12s
Cross-Chain Functionality Tests / test-cross-chain-bridge (push) Has been skipped
Cross-Node Transaction Testing / transaction-test (push) Has been cancelled
Cross-Chain Functionality Tests / test-multi-chain-consensus (push) Failing after 8s
Deploy to Testnet / deploy-testnet (push) Has been cancelled
Cross-Chain Functionality Tests / aggregate-results (push) Has been skipped
Deploy to Testnet / notify-deployment (push) Has been cancelled
Integration Tests / test-service-integration (push) Has started running
Multi-Node Stress Testing / stress-test (push) Has been cancelled
Multi-Node Blockchain Health Monitoring / health-check (push) Successful in 7s
Node Failover Simulation / failover-test (push) Has been cancelled
Python Tests / test-python (push) Has been cancelled
Security Scanning / security-scan (push) Has been cancelled
P2P Network Verification / p2p-verification (push) Successful in 10s
- Fixed bare except clauses in blockchain-node p2p_network.py - Fixed bare except clauses in blockchain-node rpc/router.py - Fixed bare except clauses in coordinator-api migration scripts - Fixed bare except clause in coordinator-api agent_integration_router.py - Addresses ruff E722 warnings in critical application code - Note: 170 bare except clauses remain in tests/dev/plugins (lower priority)
77 lines
2.0 KiB
Python
77 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Fix bare except clauses by replacing 'except:' with 'except Exception:'"""
|
|
|
|
import ast
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def fix_bare_except(file_path):
|
|
"""Fix bare except clauses in a Python file"""
|
|
try:
|
|
with open(file_path, 'r') as f:
|
|
content = f.read()
|
|
|
|
# Parse the file to check for syntax errors
|
|
try:
|
|
ast.parse(content)
|
|
except SyntaxError:
|
|
print(f"Skipping {file_path}: syntax error")
|
|
return False
|
|
|
|
# Split into lines
|
|
lines = content.split('\n')
|
|
modified = False
|
|
new_lines = []
|
|
|
|
i = 0
|
|
while i < len(lines):
|
|
line = lines[i]
|
|
stripped = line.strip()
|
|
|
|
# Check if this is a bare except statement
|
|
if stripped == 'except:':
|
|
# Check if the previous line is a try block
|
|
if i > 0 and 'try:' in lines[i-1]:
|
|
# Replace with except Exception:
|
|
new_lines.append(line.replace('except:', 'except Exception:'))
|
|
modified = True
|
|
else:
|
|
new_lines.append(line)
|
|
else:
|
|
new_lines.append(line)
|
|
|
|
i += 1
|
|
|
|
if modified:
|
|
with open(file_path, 'w') as f:
|
|
f.write('\n'.join(new_lines))
|
|
print(f"Fixed {file_path}")
|
|
return True
|
|
return False
|
|
except Exception as e:
|
|
print(f"Error processing {file_path}: {e}")
|
|
return False
|
|
|
|
|
|
def main():
|
|
"""Main function"""
|
|
if len(sys.argv) > 1:
|
|
root = Path(sys.argv[1])
|
|
else:
|
|
root = Path('.')
|
|
|
|
# Find all Python files
|
|
py_files = list(root.rglob('*.py'))
|
|
|
|
fixed_count = 0
|
|
for py_file in py_files:
|
|
if fix_bare_except(py_file):
|
|
fixed_count += 1
|
|
|
|
print(f"\nFixed {fixed_count} files")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|