{"id":2056,"library":"groovy","title":"Groovy (Python-to-JavaScript Transpiler)","description":"Groovy is a Python-to-JavaScript transpiler that converts Python functions to their JavaScript equivalents. It is primarily used within the Gradio library, allowing developers to write Python functions that execute efficiently as client-side JavaScript. The library prioritizes clear error reporting for unsupported Python code over full Python feature coverage. The current version is 0.1.2, with development appearing active due to its integration with Gradio.","status":"active","version":"0.1.2","language":"en","source_language":"en","source_url":"https://github.com/gradio-app/groovy","tags":["transpiler","javascript","gradio","frontend"],"install":[{"cmd":"pip install groovy","lang":"bash","label":"Install stable release"}],"dependencies":[{"reason":"Requires Python 3.9 or higher for execution.","package":"python","optional":false}],"imports":[{"symbol":"transpile","correct":"from groovy import transpile"}],"quickstart":{"code":"from groovy import transpile\n\ndef sum_range(n: int) -> int:\n    total = 0\n    for i in range(n):\n        total = total + i\n    return total\n\njs_code = transpile(sum_range)\nprint(js_code)\n# Expected output (may vary slightly in formatting):\n# function sum_range(n) {\n#   let total = 0;\n#   for (let i of Array.from({length: n}, (_, i) => i)) {\n#     total = (total + i);\n#   }\n#   return total;\n# }","lang":"python","description":"This example demonstrates how to transpile a simple Python function into its JavaScript equivalent using the `transpile` function."},"warnings":[{"fix":"Verify the library's description on PyPI or its GitHub repository before installation to confirm it matches the intended functionality.","message":"This 'groovy' library (version 0.1.2) is a Python-to-JavaScript transpiler. Be aware of potential name collisions with other Python packages also named 'groovy' on PyPI that serve different purposes (e.g., a workflow automation tool or a Groovy language parser). Ensure you are installing and using the correct library for your needs.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consult the official documentation for supported Python features and modify your Python functions accordingly to ensure successful transpilation. The library provides clear error reporting with line numbers.","message":"Groovy does not provide full Python feature coverage; it supports only a subset of the Python standard library and some Gradio-specific classes. Attempting to transpile unsupported Python syntax will result in a `TranspilationError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Focus on the functional equivalence and return values of the transpiled code. Avoid making assumptions about the exact internal structure of the generated JavaScript unless explicitly documented as stable.","message":"While Groovy aims to guarantee identical return values for transpiled functions, the internal JavaScript implementation may differ slightly from the Python version (e.g., Python tuples might be converted to JavaScript arrays). This can lead to unexpected behavior if introspection or strict type checking of the transpiled JavaScript's internal structure is performed.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}