- Go to your project folder
cd my-projectUse your own folder name.
- Create a virtual environment
python3 -m venv .venvSkip this if your project already has one.
- Switch it on
source .venv/bin/activateYour prompt now starts with (.venv).
- Install Ruff
pip install ruff - Check for problems
ruff check .Lists unused imports, undefined names and other likely mistakes, with the file and line of each.
- Fix what Ruff can fix by itself
ruff check --fix .Removes unused imports and similar easy fixes. Anything it can't fix stays in the list.
- Format every file
ruff format .Rewrites spacing, quotes and line breaks in one consistent style, like Black.
- See the formatting changes without saving them
ruff format --diff app.py
Check it worked
- Check the whole project is clean
ruff check . && ruff format --check .Prints All checks passed! and says how many files are already formatted.
Undo it
- Put the files back as they were
git restore .Only works if the project is in Git. It throws away every change since your last commit, not just Ruff's, so commit your own work first.
- Remove Ruff
pip uninstall -y ruff
- Go to your project folder
cd my-projectUse your own folder name.
- Create a virtual environment
python3 -m venv .venvSkip this if your project already has one. On Debian and Ubuntu you may need sudo apt install python3-venv first.
- Switch it on
source .venv/bin/activateYour prompt now starts with (.venv).
- Install Ruff
pip install ruff - Check for problems
ruff check .Lists unused imports, undefined names and other likely mistakes, with the file and line of each.
- Fix what Ruff can fix by itself
ruff check --fix .Removes unused imports and similar easy fixes. Anything it can't fix stays in the list.
- Format every file
ruff format .Rewrites spacing, quotes and line breaks in one consistent style, like Black.
- See the formatting changes without saving them
ruff format --diff app.py
Check it worked
- Check the whole project is clean
ruff check . && ruff format --check .Prints All checks passed! and says how many files are already formatted.
Undo it
- Put the files back as they were
git restore .Only works if the project is in Git. It throws away every change since your last commit, not just Ruff's, so commit your own work first.
- Remove Ruff
pip uninstall -y ruff
- Go to your project folder
cd my-projectUse your own folder name.
- Create a virtual environment
py -m venv .venvSkip this if your project already has one.
- Switch it on
.venv\Scripts\Activate.ps1Your prompt now starts with (.venv).
- Install Ruff
pip install ruff - Check for problems
ruff check .Lists unused imports, undefined names and other likely mistakes, with the file and line of each.
- Fix what Ruff can fix by itself
ruff check --fix .Removes unused imports and similar easy fixes. Anything it can't fix stays in the list.
- Format every file
ruff format .Rewrites spacing, quotes and line breaks in one consistent style, like Black.
- See the formatting changes without saving them
ruff format --diff app.py
Check it worked
- Check the whole project is clean
ruff check .; ruff format --check .Prints All checks passed! and says how many files are already formatted.
Undo it
- Put the files back as they were
git restore .Only works if the project is in Git. It throws away every change since your last commit, not just Ruff's, so commit your own work first.
- Remove Ruff
pip uninstall -y ruff