From d335904f6f06e5b878fa59ae83c1a260cc0bc691 Mon Sep 17 00:00:00 2001 From: Kieran Ryan Date: Mon, 23 Dec 2024 18:11:34 +0000 Subject: [PATCH] feat: 'notebook' extra requirement with nbformat Simplifies `pip install radon nbformat` to `pip install radon[notebook]`. Protects against changing underlying dependency in future. --- README.rst | 8 +++++--- docs/commandline.rst | 6 ++++-- setup.py | 5 ++++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index 0bcbdee..3b32ae5 100644 --- a/README.rst +++ b/README.rst @@ -51,7 +51,7 @@ With Pip: $ pip install radon If you want to configure Radon from `pyproject.toml` and you run Python <3.11, -you'll need the extra `toml` dependency: +you will need to install the extra `toml` dependency: .. code-block:: sh @@ -159,9 +159,11 @@ Usage with Jupyter Notebooks Radon can be used with ``.ipynb`` files to inspect code metrics for Python cells. Any ``%`` macros will be ignored in the metrics. -.. note:: +You will need to install the extra `notebook` dependency: - Jupyter Notebook support requires the optional ``nbformat`` package. To install, run ``pip install nbformat``. +.. code-block:: sh + + $ pip install radon[notebook] To enable scanning of Jupyter notebooks, add the ``--include-ipynb`` flag. diff --git a/docs/commandline.rst b/docs/commandline.rst index 44776ed..7115035 100644 --- a/docs/commandline.rst +++ b/docs/commandline.rst @@ -42,9 +42,11 @@ Usage with Jupyter Notebooks Radon can be used with ``.ipynb`` files to inspect code metrics for Python cells. Any ``%`` macros will be ignored in the metrics. -.. note:: +You will need to install the extra `notebook` dependency: + +.. code-block:: sh - Jupyter Notebook support requires the optional ``nbformat`` package. To install, run ``pip install nbformat``. + $ pip install radon[notebook] To enable scanning of Jupyter notebooks, add the ``--include-ipynb`` flag with any of the commands. diff --git a/setup.py b/setup.py index 72258c6..aadf654 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,7 @@ import os + from setuptools import setup, find_packages + import radon @@ -27,7 +29,8 @@ 'colorama>=0.4.1;python_version>"3.4"', ], extras_require={ - 'toml': ["tomli>=2.0.1"] + 'toml': ["tomli>=2.0.1"], + 'notebook': ['nbformat'], }, entry_points={ 'console_scripts': ['radon = radon:main'],