You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24-26Lines changed: 24 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,22 +5,20 @@
5
5
6
6
## Overview
7
7
8
-
**`colablinter`** is an **IPython magic command extension** designed specifically for Jupyter and Google Colab notebooks.
9
-
10
-
It integrates the high-speed linter **`ruff`** to perform code quality checks and enforce standards directly within Jupyter/Colab cells.
11
-
12
-
It allows developers to lint and format code on a **cell-by-cell** basis or check the **entire notebook** with simple commands.
8
+
**`colablinter`** is an **IPython magic command extension** designed for Jupyter and Google Colab notebooks.
9
+
It integrates the high-speed linter **`ruff`** to perform code quality checks and formatting directly within Jupyter/Colab cells.
10
+
It allows developers to lint code on a **cell-by-cell** basis or the **entire notebook** with simple commands.
13
11
14
12
## Magic cell Commands
15
13
16
-
| Command |Type |Description |
17
-
| :--- | :--- | :--- |
18
-
|**`%%cfix`**|Cell Magic | Fixes and Formats the current cell's code. |
19
-
|**`%%creport`**| Cell Magic| Displays a linting report for the current cell. |
20
-
|**`%clautofix`**|Line Magic |Activates or deactivates automatic code fixing and formatting before every cell execution. |
21
-
|**`%clreport`**| Line Magic| Displays a linting report for the **entire saved notebook** (requires Google Drive mount). |
14
+
| Command | Description |
15
+
| :--- | :--- |
16
+
|**`%%cformat`**|Sorts imports and Formats the current cell's code. |
17
+
|**`%%ccheck`**| Displays a linting report for the current cell. |
18
+
|**`%lautoformat`**| Activates or deactivates automatic import sorting, formatting, and execution time display before every cell. |
19
+
|**`%lcheck`**| Displays a linting report for the **entire saved notebook** (requires Google Drive mount). |
22
20
23
-
After executing a cell magic command, the fixed/reported code is immediately executed (if applicable), maintaining the notebook workflow.
21
+
After executing a cell magic command, the checked/formatted code is immediately executed (if applicable), maintaining the notebook workflow.
24
22
25
23
## Installation
26
24
@@ -31,18 +29,18 @@ pip install colablinter
31
29
```
32
30
33
31
## Usage
34
-
The extension must be explicitly loaded in the notebook session before use. Once the extension is loaded, `%clautofix` is triggered automatically.
32
+
The extension must be explicitly loaded in the notebook session before use. Once the extension is loaded, `%lautoformat` is activated by default.
35
33
36
34
```python
37
35
%load_ext colablinter
38
36
```
39
37
40
38
41
-
1.Fix and Format cell (`%%cfix`)
39
+
1.Sorts imports and Formats cell (`%%cformat`)
42
40
43
-
`%%cfix` corrects code and runs the formatter. The cell executes the fixed code.
41
+
`%%cformat` corrects code and runs the formatter. The cell executes after cell is formatted.
44
42
```python
45
-
%%cfix
43
+
%%cformat
46
44
import math, sys;
47
45
48
46
classExample( object ):
@@ -70,11 +68,11 @@ The extension must be explicitly loaded in the notebook session before use. Once
70
68
return (sys.path, some_string)
71
69
```
72
70
73
-
2. Check cell quality (`%%creport`)
71
+
2. Check cell quality (`%%ccheck`)
74
72
75
-
Use `%%creport` to see linting reports for the code below the command. After the report is displayed, the code in the cell executes as normal.
73
+
Use `%%ccheck` to see linting reports for the code below the command. After the report is displayed, the code in the cell executes as normal.
76
74
```python
77
-
%%creport
75
+
%%ccheck
78
76
79
77
definvalid_code(x):
80
78
return x + y # 'y' is not defined
@@ -95,23 +93,23 @@ The extension must be explicitly loaded in the notebook session before use. Once
95
93
**Note on F401:**
96
94
The linter is explicitly configured to **ignore F401 errors** (unused imports). This is to ensure compatibility with the stateful nature of Jupyter/Colab notebooks, where imports in one cell may be necessary for code execution in subsequent cells, preventing unintended breakage of the notebook's execution flow.
97
95
98
-
3. Activate/Deactivate Auto Fix (`%clautofix`)
96
+
3. Activate/Deactivate Auto Fix (`%lautoformat`)
99
97
100
-
The `%clautofix` line magic allows you to automatically fix code before every code cell is executed.
98
+
The `%lautoformat` line magic allows you to automatically fix code before every code cell is executed.
101
99
102
100
To Activate Auto Fixing:
103
101
```python
104
-
%clautofix on # %clautofix off when you want to deactivate
102
+
%lautoformat on # %lautoformat off when you want to deactivate
105
103
```
106
104
107
-
4. Check entire notebook (`%clreport`)
105
+
4. Check entire notebook (`%lcheck`)
108
106
109
-
Use line magic `%clreport` to check across the entire saved notebook file (requires the notebook to be saved to Google Drive and mounted).
107
+
Use line magic `%lcheck` to check across the entire saved notebook file (requires the notebook to be saved to Google Drive and mounted).
Magic Command Execution: When using magic or terminal commands with`%clautofix` on active, the autofix mechanism is temporarily suppressed during the final execution step to prevent infinite loops or dual checks. If you want to disable auto-fixing, use `%clautofix off`
115
+
Magic Command Execution: When using magic or terminal commands while`%lautoformat`is active, the auto-format mechanism is temporarily suppressed during the final execution step to prevent infinite loops or dual checks. If you want to disable auto-formatting, use `%lautoformat off`
0 commit comments