Skip to content

Commit

Permalink
feat: 'notebook' extra requirement with nbformat
Browse files Browse the repository at this point in the history
Simplifies `pip install radon nbformat` to `pip install radon[notebook]`.
Protects against changing underlying dependency in future.
  • Loading branch information
kieran-ryan committed Dec 23, 2024
1 parent d021626 commit 939ee14
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
8 changes: 5 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand Down
6 changes: 4 additions & 2 deletions docs/commandline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
5 changes: 4 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ colorama = [
{version = "==0.4.1", markers = "python_version == \"3.4\""}
]

# A list of all of the optional dependencies, which are included in the
# below `extras`. They can be opted into by apps.
# https://python-poetry.org/docs/pyproject/#extras
nbformat = { version = "*", optional = true }

[tool.poetry.group.dev.dependencies]
coverage = "*"
coveralls = "*"
Expand All @@ -23,6 +28,9 @@ argparse = "*"
nbformat = "*"
tox = "^4.4.7"

[tool.poetry.extras]
notebook = ["nbformat"]

[tool.poetry.scripts]
radon = "radon:main"

Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os

from setuptools import setup, find_packages

import radon


Expand Down Expand Up @@ -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'],
Expand Down

0 comments on commit 939ee14

Please sign in to comment.