Skip to content

Commit

Permalink
DX: automatically list jupyterlab requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Nov 29, 2023
1 parent 2be67a6 commit e2c3ddf
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"indentless",
"ipynb",
"jsonschema",
"jupyterlab",
"linkcheck",
"maxdepth",
"maxsplit",
Expand Down
3 changes: 3 additions & 0 deletions src/repoma/check_dev_files/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
github_labels,
github_workflows,
gitpod,
jupyter,
mypy,
nbstripout,
precommit,
Expand Down Expand Up @@ -58,6 +59,8 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
skip_tests=_to_list(args.ci_skipped_tests),
test_extras=_to_list(args.ci_test_extras),
)
if has_notebooks:
executor(jupyter.main)
executor(nbstripout.main)
executor(toml.main) # has to run before pre-commit
executor(prettier.main, args.no_prettierrc)
Expand Down
26 changes: 26 additions & 0 deletions src/repoma/check_dev_files/jupyter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Update the developer setup when using Jupyter notebooks."""

from repoma.utilities.executor import Executor
from repoma.utilities.project_info import get_supported_python_versions
from repoma.utilities.pyproject import add_dependency


def main() -> None:
_update_dev_requirements()


def _update_dev_requirements() -> None:
if "3.6" in get_supported_python_versions():
return
hierarchy = ["jupyter", "dev"]
dependencies = [
"jupyterlab",
"jupyterlab-code-formatter",
"jupyterlab-lsp",
"jupyterlab-myst",
"python-lsp-server[rope]",
]
executor = Executor()
for dependency in dependencies:
executor(add_dependency, dependency, optional_key=hierarchy)
executor.finalize()
3 changes: 2 additions & 1 deletion src/repoma/utilities/pyproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def add_dependency( # noqa: C901, PLR0912
executor(
add_dependency, f"{this_package}[{previous}]", key, source, target
)
executor.finalize()
if executor.finalize() == 0:
return
else:
msg = f"Unsupported type for optional_key: {type(optional_key)}"
raise NotImplementedError(msg)
Expand Down

0 comments on commit e2c3ddf

Please sign in to comment.