What is Pyrfecter?
Pyrfecter is a Python code linter, formatter, and improver that runs entirely in your browser. It uses Pyodide under the hood, along with a number of excellent Python code quality tools (listed below).
What can I expect?
Cleaner Python code! Pyrfecter aims to be maximally helpful and minimally disruptive by performing a number of improvements to your Python code without changing how it works. (That's the goal, anyway. If your code was changed in a breaking way, please get in touch.)
Code is formatted to Black's default of 88 characters. This might be configurable in the future, but for now if you want to reformat your code with a different line length, you can do that in the Black playground:
- Visit the Black playground at https://black.vercel.app
- Click the settings gear (⚙️) in the bottom left
- Specify your new line length in the "Line Length" input
- Wait for your code to be reformatted automatically
Why should I use Pyrfecter?
That's a good question. Pyrfecter was designed to be used to tidy up Python on-the-fly. Maybe you have a Python code snippet you want to include in documentation for a project that doesn't have a
Are there other tools that do similar things?
Certainly! Some of the tools Pyrfecter uses have online playgrounds where you can see how the tool will affect your code.
If you're looking only to format your code with Black, you can use Black's playground: https://black.vercel.app/
If you just want to sort your imports, you can use isort's live editor at https://pycqa.github.io/isort/docs/quick_start/0.-try.html.
For regular Python development, it's a good practice to configure your code editor to lint your code as you type for format/fix your code when you commit it (or even when you save it). pre-commit is an excellent tool to run Python formatters, linters, and fixers right after you do a
git commit but before you write your commit message. pre-commit hooks are available for a number of the code quality tools Pyrfecter uses (listed below).
Code quality tools
Here's a list of code quality tools used by Pyrfecter, along with a link to their homepage and, if they have one, an example of how to use their tool as a pre-commit hook.
"The uncompromising Python code formatter"
"A simple program which checks Python source files for errors"
"[A] Python utility / library to sort imports alphabetically, [...] separated into sections and by type"
A "[t]ool for fixing trivial problems with your code."
"A tool and pre-commit hook to automatically apply the awesome walrus operator."
"A tool to automatically convert old string literal formatting to f-strings"
A "McCabe complexity checker for Python"