refactor(types): auto -> None sweep across entire codebase
Applied 236 return type annotations to functions with no return values across 100+ files (core modules, tests, scripts, simulations). Added Phase 4 to python_style_refactor track for remaining 597 items (untyped params, vars, and functions with return values). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -253,7 +253,7 @@ def create_parser():
|
||||
return parser
|
||||
|
||||
|
||||
def main():
|
||||
def main() -> None:
|
||||
parser = create_parser()
|
||||
args = parser.parse_args()
|
||||
role = args.role
|
||||
|
||||
@@ -15,7 +15,7 @@ except ImportError:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main():
|
||||
def main() -> None:
|
||||
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s', stream=sys.stderr)
|
||||
logging.debug("Claude Tool Bridge script started.")
|
||||
try:
|
||||
|
||||
@@ -78,7 +78,7 @@ async def call_tool(name: str, arguments: dict) -> list[TextContent]:
|
||||
return [TextContent(type="text", text=f"ERROR: {e}")]
|
||||
|
||||
|
||||
async def main():
|
||||
async def main() -> None:
|
||||
async with stdio_server() as (read_stream, write_stream):
|
||||
await server.run(
|
||||
read_stream,
|
||||
|
||||
@@ -239,7 +239,7 @@ def create_parser():
|
||||
)
|
||||
return parser
|
||||
|
||||
def main():
|
||||
def main() -> None:
|
||||
parser = create_parser()
|
||||
args = parser.parse_args()
|
||||
role = args.role
|
||||
|
||||
56
scripts/scan_all_hints.py
Normal file
56
scripts/scan_all_hints.py
Normal file
@@ -0,0 +1,56 @@
|
||||
"""Scan all .py files for missing type hints. Writes scan_report.txt."""
|
||||
import ast, os
|
||||
|
||||
SKIP = {'.git', '__pycache__', '.venv', 'venv', 'node_modules', '.claude', '.gemini'}
|
||||
BASE = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
os.chdir(BASE)
|
||||
|
||||
results = {}
|
||||
for root, dirs, files in os.walk('.'):
|
||||
dirs[:] = [d for d in dirs if d not in SKIP]
|
||||
for f in files:
|
||||
if not f.endswith('.py'):
|
||||
continue
|
||||
path = os.path.join(root, f).replace('\\', '/')
|
||||
try:
|
||||
with open(path, 'r', encoding='utf-8-sig') as fh:
|
||||
tree = ast.parse(fh.read())
|
||||
except Exception:
|
||||
continue
|
||||
counts = [0, 0, 0] # nr, up, uv
|
||||
def scan(scope, prefix=''):
|
||||
for node in ast.iter_child_nodes(scope):
|
||||
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
|
||||
if node.returns is None:
|
||||
counts[0] += 1
|
||||
for arg in node.args.args:
|
||||
if arg.arg not in ('self', 'cls') and arg.annotation is None:
|
||||
counts[1] += 1
|
||||
if isinstance(node, ast.Assign):
|
||||
for t in node.targets:
|
||||
if isinstance(t, ast.Name):
|
||||
counts[2] += 1
|
||||
if isinstance(node, ast.ClassDef):
|
||||
scan(node, prefix=f'{node.name}.')
|
||||
scan(tree)
|
||||
nr, up, uv = counts
|
||||
total = nr + up + uv
|
||||
if total > 0:
|
||||
results[path] = (nr, up, uv, total)
|
||||
|
||||
lines = []
|
||||
lines.append(f'Files with untyped items: {len(results)}')
|
||||
lines.append('')
|
||||
lines.append(f'{"File":<58} {"NoRet":>6} {"Params":>7} {"Vars":>5} {"Total":>6}')
|
||||
lines.append('-' * 85)
|
||||
gt = 0
|
||||
for path in sorted(results, key=lambda x: results[x][3], reverse=True):
|
||||
nr, up, uv, t = results[path]
|
||||
lines.append(f'{path:<58} {nr:>6} {up:>7} {uv:>5} {t:>6}')
|
||||
gt += t
|
||||
lines.append('-' * 85)
|
||||
lines.append(f'{"TOTAL":<58} {"":>6} {"":>7} {"":>5} {gt:>6}')
|
||||
|
||||
report = '\n'.join(lines)
|
||||
with open('scan_report.txt', 'w', encoding='utf-8') as f:
|
||||
f.write(report)
|
||||
@@ -17,7 +17,7 @@ except ImportError:
|
||||
print(json.dumps({"error": "Failed to import required modules"}))
|
||||
sys.exit(1)
|
||||
|
||||
def main():
|
||||
def main() -> None:
|
||||
if len(sys.argv) < 2:
|
||||
print(json.dumps({"error": "No tool name provided"}))
|
||||
sys.exit(1)
|
||||
|
||||
@@ -13,7 +13,7 @@ except ImportError as e:
|
||||
print("[]")
|
||||
sys.exit(0)
|
||||
|
||||
def main():
|
||||
def main() -> None:
|
||||
specs = list(mcp_client.MCP_TOOL_SPECS)
|
||||
# Add run_powershell (manually define to match ai_client.py)
|
||||
specs.append({
|
||||
|
||||
Reference in New Issue
Block a user