Linting and formatting Python code in Google Colab.
Project description
colablinter
Overview
colablinter is an IPython magic command extension for Jupyter and Google Colab environments.
It integrates the high-speed linter ruff and import sorter isort to perform cell-by-cell code quality and formatting checks.
Magic Commands
| Command | Role | Description |
|---|---|---|
%%check |
Quality Check | Displays a linting report. |
%%format |
Format, Sort | Displays a formatting preview (for copy/paste) |
After executing a magic command, the original code of the cell is executed (if applicable to the command).
Full Notebook Check
| function | Description |
|---|---|
check_full() |
Displays a linting report for entire notebook. |
Installation
Requires Python 3.12 or newer.
pip install colablinter
Usage
The extension must be explicitly loaded in the notebook session before use.
%load_ext colablinter
-
Check Code Quality
Use
%%checkto see linting reports.%%check def invalid_code(x): return x + y # 'y' is not defined
Output examples:
---- Code Quality & Style Check Report ---- F821 Undefined name `y` --> notebook_cell.py:3:16 | 2 | def invalid_code(x): 3 | return x + y # 'y' is not defined | ^ | Found 1 error. -------------------------------------------
-
Format code preview
%%formatwill display the formatted code, but the cell executes the original code.%%format import sys import os def calculate_long_sum(a,b,c,d,e,f): return (a+b+c)*(d+e+f) # messy
Output examples:
# Formatted Code import os import sys from datetime import datetime def calculate_long_sum(a, b, c, d, e, f): return (a + b + c) * (d + e + f) # messy
-
Full notebook check
Use
check_full()to see linting reports for entire notebook.check_full()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file colablinter-0.0.3.tar.gz.
File metadata
- Download URL: colablinter-0.0.3.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f69bbf98bcbac1b97ed055bee3d5d9036179cd2c14e0f6d3407ad6bec7df205
|
|
| MD5 |
c652dbdc7b46ad47a711debc94814aa2
|
|
| BLAKE2b-256 |
6469c272c313649b2a9dcb095bd0d11513202c41a457ff07bdb45c2faa330f1e
|
File details
Details for the file colablinter-0.0.3-py3-none-any.whl.
File metadata
- Download URL: colablinter-0.0.3-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1949303eaae130dfa898cf2d4b1feef82da1701673670b16914a8ac6c14e5b43
|
|
| MD5 |
80a793340335cf06cdb7ee8c85fa1fa5
|
|
| BLAKE2b-256 |
ebe0441030c44ae9ec506ae411986c67b9f6746c174e63770186145eadb4c1cb
|