Skip to main content

Linting and formatting Python code in Google Colab.

Project description

colablinter

PyPI version License: MIT

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 cell Commands

Command Role Description
%%cl_check Quality Check Displays a linting report.
%%cl_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).

Magic line Commands

Command Role Description
%cl_check Quality Check 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
  1. Check Code Quality

    Use %%cl_check to see linting reports.

    %%cl_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.
    -------------------------------------------
    
  2. Format code preview

    %%cl_format will display the formatted code, but the cell executes the original code.

    %%cl_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
    
  3. Full notebook check

    Use %cl_check command to see linting reports for entire notebook.

    %cl_check
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

colablinter-0.0.5.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

colablinter-0.0.5-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file colablinter-0.0.5.tar.gz.

File metadata

  • Download URL: colablinter-0.0.5.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","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

Hashes for colablinter-0.0.5.tar.gz
Algorithm Hash digest
SHA256 1b886c14219dc866d8e2cdb59d12c1c6ac215ca738f2ed61a90ff94e805c9c89
MD5 5155a89542466f6e405b381ce3946ba0
BLAKE2b-256 df3291eee0cd5659d92dd6a623c01ded1ff74a18f6a55c80a954feaee14b929f

See more details on using hashes here.

File details

Details for the file colablinter-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: colablinter-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","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

Hashes for colablinter-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8a820805e3a3d42d147600adaac8b62d9477f94ac3ff1dba5e5cc71bffc0fc2f
MD5 773a4c4704306e07163d96871f6f0bfc
BLAKE2b-256 9d0b1f587a75615b223b307e7ece627723480397b36bd78e909d6eb8124cda0a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page