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 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).

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

    %%format will 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
    

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.2.tar.gz (3.9 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.2-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: colablinter-0.0.2.tar.gz
  • Upload date:
  • Size: 3.9 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

Hashes for colablinter-0.0.2.tar.gz
Algorithm Hash digest
SHA256 6030c3c7c374d2d529037b7d397d2901e03466e9e7e84f945376f4c9dfd73e9d
MD5 e4d38ee6c28d62e727bf5021259c22e6
BLAKE2b-256 920adcbfb9d448d3f704d60154bc139883b1295980a1b98c51af9596da415361

See more details on using hashes here.

File details

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

File metadata

  • Download URL: colablinter-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.3 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

Hashes for colablinter-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 93012cebba0e4af283a898a5741c04056a13e9a5a00944855ff35b53e97feadc
MD5 faef405ee951dc819402f5f1fa866f8d
BLAKE2b-256 e23c0b6c0eee50b514516bf81f2825ed4d730218aedfdc40d78198813ef073b9

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