To add a return type, use function.set_return_type. The script below will add a -> None return type to all functions that contain no return statements:
Copy
Ask AI
for file in codebase.files: # Check if 'app' is in the file's filepath if "app" in file.filepath: # Iterate through all functions in the file for function in file.functions: # Check if the function has no return statements if len(function.return_statements) == 0: # Set the return type to None function.set_return_type("None")