Skip to content

Latest commit

 

History

History
133 lines (116 loc) · 3.86 KB

File metadata and controls

133 lines (116 loc) · 3.86 KB

Try isort from your browser!

Use our live isort editor to see how isort can help improve the formatting of your Python imports.

!!! important - "Safe to use. No code is transmitted." The below live isort tester doesn't transmit any of the code you paste to our server or anyone else's. Instead, this page runs a complete Python3 installation with isort installed entirely within your browser. To accomplish this, it utilizes the pyodide project.

<script src="https://cdn.jsdelivr.net/pyodide/v0.29.3/full/pyodide.js" integrity="sha256-cY1A8cAV3SXsckzI/E4jJdakWpKuIlEh/2lT8iShb3I=" type="text/javascript" crossorigin="anonymous" > </script> <script src="https://cdn.jsdelivr.net/npm/ace-builds@1.43.6/src-min-noconflict/ace.min.js" > </script> <style> .editor { height: 400px; width: 49.7%; display: inline-block; } .configurator { height: 200px; width: 100%; clear: both; float: left; } #liveTester { background: black; color: white; } #sideBySide { white-space: nowrap; } #liveTester.fullscreen { position: absolute; top: 0px; left: 0px; right: 0px; z-index: 99; bottom: 0px; } </style> <title>Try isort</title>
from future import braces import b import b import os import a from future import braces import b import a import b, a
Installing isort with Pyodide...

 Configuration (Note: the below must follow JSON format). Full configuration guide is here:

{"line_length": 80, "profile": "black", "atomic": true }
<script type="text/javascript"> window.addEventListener("load", () => { var input = ace.edit("inputEditor"); var output = ace.edit("outputEditor"); var configurator = ace.edit("configEditor"); [input, output, configurator].forEach((editor) => { editor.setTheme("ace/theme/monokai"); editor.session.setMode("ace/mode/python"); editor.resize(); }); configurator.session.setMode("ace/mode/json"); function updateOutput() { output.setValue(document.sort_code(input.getValue(), configurator.getValue())); } output.setReadOnly(true); input.session.on("change", updateOutput); configurator.session.on("change", updateOutput); document.updateOutput = updateOutput; }); async function main() { let pyodide = await loadPyodide(); await pyodide.loadPackage("micropip"); const micropip = pyodide.pyimport("micropip"); await micropip.install("isort"); await pyodide.runPython(` from js import document import isort import json import textwrap def sort_code(code, configuration): try: configuration = json.loads(configuration or "{}") except Exception as configuration_error: return "\\n".join(textwrap.wrap(f"Exception thrown trying to read given configuration {configuration_error}", 40)) try: return f"# Using {isort.__version__} of isort." + "\\n\\n" + isort.code(code, **configuration) except Exception as isort_error: return "\\n".join(textwrap.wrap(f"Exception thrown trying to sort given imports {isort_error}", 40)) document.sort_code = sort_code document.updateOutput() `); } main(); </script>
Like what you saw? Installing isort to use locally is as simple as `pip install isort`.

Click here for full installation instructions.