Skip to content

Commit 1d5331e

Browse files
Use ruff for repository linting instead of replacing pylint_notebook
Co-authored-by: AlexeyKozhevin <[email protected]>
1 parent 04b5255 commit 1d5331e

File tree

6 files changed

+48
-251
lines changed

6 files changed

+48
-251
lines changed

.github/workflows/status.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v1
1313

14-
- name: Update pylint
15-
run: pip3 install -U pylint
14+
- name: Install ruff
15+
run: pip3 install -U ruff
1616

17-
- name: Check pylint
18-
run: pylint -rn --rcfile pylintrc nbtools
17+
- name: Check ruff
18+
run: ruff check nbtools

docs/user_guide/nbtools.library.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@ Jupyter Notebooks: linting and execution
55
Other than `nbstat / nbwatch` monitoring utilities, this library provides a few useful tools for working with notebooks and GPUs.
66

77

8-
ruff_notebook
9-
*************
8+
pylint_notebook
9+
***************
1010

11-
Function that checks for errors in Jupyter Notebooks with Python code using `ruff <https://docs.astral.sh/ruff/>`_, a fast Python linter. It tries to enforce a coding standard, looks for code smells, and can detect various issues including imports, formatting, and potential bugs.
11+
Shamelessly taken from `pylint page <https://pylint.pycqa.org/en/latest/>`_
1212

13-
Using it is as easy as:
13+
Function that checks for errors in Jupyter Notebooks with Python code, tries to enforce a coding standard and looks for code smells. It can also look for certain type errors, it can recommend suggestions about how particular blocks can be refactored and can offer you details about the code's complexity.
1414

15-
.. code-block:: python
15+
Using it as easy as:
1616

17-
from nbtools import ruff_notebook
18-
ruff_notebook(path_to_ipynb, # If not provided, use path to the current notebook
19-
ignore=['E402', 'F401'], # Ignore specified ruff rule codes. Can be a list.
20-
config='path/to/ruff.toml') # Custom ruff configuration file
17+
.. code-block:: python
2118
22-
For backward compatibility, ``pylint_notebook`` is still available as an alias to ``ruff_notebook``.
19+
from nbtools import pylint_notebook
20+
pylint_notebook(path_to_ipynb, # If not provided, use path to the current notebook
21+
disable='invalid-name', # Disable specified Pylint checks. Can be a list.
22+
enable='import-error') # Enable specified Pylint checks. Can be a list.
2323
2424
25-
Under the hood, it converts `.ipynb` notebook to `.py` script, creates a custom `ruff.toml` configuration, runs `ruff` and removes all temporary files. Learn more about its usage in the [tutorial.](tutorials/NBstat.ipynb)
25+
Under the hood, it converts `.ipynb` notebook to `.py` script, creates a custom `.pylintrc` configuration, runs the `pylint` and removes all temporary files. Learn more about its usage in the [tutorial.](tutorials/NBstat.ipynb)
2626

2727
exec_notebook
2828
*************

nbtools/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
""" Init file. """
2+
#pylint: disable=wildcard-import
23
from .core import *
34
from .exec_notebook import exec_notebook, run_notebook
4-
from .ruff_notebook import ruff_notebook, pylint_notebook
5+
from .pylint_notebook import pylint_notebook
56

67
__version__ = '0.9.14'

nbtools/ruff_notebook.py

Lines changed: 0 additions & 234 deletions
This file was deleted.

pylintrc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[MASTER]
2+
extension-pkg-whitelist=numpy
3+
init-hook='import sys; sys.path.append(".")'
4+
5+
[FORMAT]
6+
max-line-length=120
7+
max-statements=100
8+
max-attributes=50
9+
max-public-methods=50
10+
max-args=50
11+
max-locals=50
12+
max-branches=50
13+
variable-rgx=(.*[a-z][a-z0-9_]{1,30}|[a-z_])$ # snake_case + single letters
14+
argument-rgx=(.*[a-z][a-z0-9_]{1,30}|[a-z_])$ # snake_case + single letters
15+
16+
[MESSAGE CONTROL]
17+
disable=import-error, relative-beyond-top-level, attribute-defined-outside-init, unnecessary-lambda-assignment,
18+
consider-iterating-dictionary, possibly-used-before-assignment
19+
20+
[TYPECHECK]
21+
ignored-modules=numpy, numba
22+
23+
[BASIC]
24+
class-rgx=[A-Z_][a-zA-Z0-9_]+$
25+
good-names=bar,df,fn
26+
27+
[MISCELLANEOUS]
28+
notes=

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@
3131
'blessed>=1.17',
3232
'psutil>=5.6',
3333
'requests>=2.24',
34-
'ruff>=0.1.0',
3534
],
3635
extras_require={
3736
'nbrun': [
3837
'ipython>=7.10.0',
3938
'nbconvert>=5.6.1',
4039
],
40+
'dev': [
41+
'ruff>=0.1.0',
42+
],
4143
},
4244
classifiers=[
4345
'Development Status :: 4 - Beta',

0 commit comments

Comments
 (0)