[build-system]
requires = ["hatchling>=1.11", "jupyterlab>=4.4.0a1,<4.5"]
build-backend = "hatchling.build"

[project]
name = "notebook"
description = "Jupyter Notebook - A web-based notebook environment for interactive computing"
readme = "README.md"
license = { file = "LICENSE" }
requires-python = ">=3.8"
authors = [
    { name = "Jupyter Development Team", email = "jupyter@googlegroups.com" },
]
keywords = [
    "Jupyter",
    "JupyterLab",
    "Notebook",
]
classifiers = [
    "Framework :: Jupyter",
    "Intended Audience :: Developers",
    "Intended Audience :: Science/Research",
    "Intended Audience :: System Administrators",
    "License :: OSI Approved :: BSD License",
    "Programming Language :: Python",
    "Programming Language :: Python :: 3.9",
    "Programming Language :: Python :: 3.10",
    "Programming Language :: Python :: 3.11",
    "Programming Language :: Python :: 3.12",
    "Programming Language :: Python :: 3.13",
    "Typing :: Typed",
]
dependencies = [
    "jupyter_server>=2.4.0,<3",
    "jupyterlab>=4.4.0a1,<4.5",
    "jupyterlab_server>=2.27.1,<3",
    "notebook_shim>=0.2,<0.3",
    "tornado>=6.2.0",
]
dynamic = ["version"]

[project.scripts]
jupyter-notebook = "notebook.app:main"

[project.urls]
Documentation = "https://jupyter-notebook.readthedocs.io/"
Homepage = "https://github.com/jupyter/notebook"
Source = "https://github.com/jupyter/notebook"
Tracker = "https://github.com/jupyter/notebook/issues"

[project.optional-dependencies]
test = [
    "nbval",
    "pytest>=7.0",
    "requests",
    "pytest-tornasync",
    "pytest-timeout",
    "pytest-console-scripts",
    "ipykernel",
    "jupyter_server[test]>=2.4.0,<3",
    "jupyterlab_server[test]>=2.27.1,<3",
    "importlib-resources>=5.0;python_version<\"3.10\"",
]
docs = [
    "myst_parser",
    "nbsphinx",
    "pydata-sphinx-theme",
    "sphinx>=1.3.6",
    "sphinxcontrib_github_alt",
    "sphinxcontrib_spelling"
]
dev = [
    "pre-commit",
    "hatch"
]

[tool.hatch.version]
path = "notebook/_version.py"
validate-bump = false

[tool.hatch.build.targets.wheel.shared-data]
"notebook/labextension" = "share/jupyter/labextensions/@jupyter-notebook/lab-extension"
"notebook/schemas/@jupyter-notebook" = "share/jupyter/lab/schemas/@jupyter-notebook"
"jupyter-config/jupyter_server_config.d" = "etc/jupyter/jupyter_server_config.d"
"notebook.svg" = "share/icons/hicolor/scalable/apps/notebook.svg"
"jupyter-notebook.desktop" = "share/applications/jupyter-notebook.desktop"

[tool.hatch.build.targets.sdist]
artifacts = [
    "notebook/labextension",
    "notebook/static",
    "notebook/schemas/@jupyter-notebook",
    "notebook/templates",
    "notebook.svg",
    "jupyter-notebook.desktop",
]
include = [
    "/jupyter-config",
    "/notebook",
    "/tests",
    "/package.json",
    "/install.json",
    "/ts*.json",
    "/*.md"
]

[tool.hatch.build.targets.wheel]
artifacts = [
    "notebook/static",
    "notebook/templates",
]
include = ["/notebook"]

[tool.hatch.envs.docs]
features = ["docs"]
[tool.hatch.envs.docs.scripts]
build = "make -C docs html SPHINXOPTS='-W'"
serve = "cd docs/build/html && python -m http.server"

[tool.hatch.envs.default.scripts]
npm_pack = "jlpm lerna exec -- npm pack"
js_test = "jlpm run build:test && jlpm run test"

[tool.hatch.envs.test]
features = ["test"]
[tool.hatch.envs.test.scripts]
test = "python -m pytest -vv {args}"
nowarn = "test -W default {args}"

[tool.hatch.envs.cov]
features = ["test"]
dependencies = ["coverage[toml]", "pytest-cov"]
[tool.hatch.envs.cov.scripts]
test = "python -m pytest -vv --cov notebook --cov-branch --cov-report term-missing:skip-covered {args}"
nowarn = "test -W default {args}"

[tool.hatch.envs.lint]
detached = true
dependencies = ["pre-commit"]
[tool.hatch.envs.lint.scripts]
build = [
    "pre-commit run --all-files ruff",
    "pre-commit run --all-files ruff-format"
]

[tool.hatch.envs.typing]
dependencies = [ "pre-commit"]
detached = true
[tool.hatch.envs.typing.scripts]
test = "pre-commit run --all-files --hook-stage manual mypy"

[tool.hatch.build.hooks.jupyter-builder]
dependencies = ["hatch-jupyter-builder>=0.5"]
build-function = "hatch_jupyter_builder.npm_builder"
ensured-targets = [
    "notebook/labextension/static/style.js",
]
install-pre-commit-hook = true

[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
build_cmd = "build:prod"
source_dir = "packages"
build_dir = "notebook/static"
npm = ["jlpm"]

[tool.hatch.build.hooks.jupyter-builder.editable-build-kwargs]
build_cmd = "build"
source_dir = "packages"
build_dir = "notebook/static"
npm = ["jlpm"]

[tool.jupyter-releaser.options]
version-cmd = "jlpm run release:bump --force --skip-commit"

[tool.jupyter-releaser.hooks]
before-bump-version = [
    "python -m pip install -U \"jupyterlab>=4.4.0a1,<4.5\"",
    "jlpm",
    "jlpm run build:utils",
    "python -m pip install hatch"
]
before-build-npm = [
    "jlpm clean",
    "jlpm build:prod"
]
before-build-python = [
    "jlpm clean"
]

[tool.pytest.ini_options]
minversion = "6.0"
xfail_strict = true
log_cli_level = "info"
addopts = [
  "-ra", "--durations=10", "--color=yes", "--doctest-modules",
   "--showlocals", "--strict-markers", "--strict-config"
]
testpaths = [
    "tests/",
]
timeout = 300
filterwarnings = [
    "error",
    "ignore:There is no current event loop:DeprecationWarning",
    "ignore:make_current is deprecated; start the event loop first",
    "ignore:clear_current is deprecated",
    "ignore:datetime.utc.* is deprecated",
    "ignore:datetime.datetime.* is deprecated",
]

[tool.coverage.report]
exclude_lines = [
  "pragma: no cover",
  "def __repr__",
  "if self.debug:",
  "if settings.DEBUG",
  "raise AssertionError",
  "raise NotImplementedError",
  "if 0:",
  "if __name__ == .__main__.:",
  "class .*\bProtocol\\):",
"@(abc\\.)?abstractmethod",
]

[tool.coverage.run]
relative_files = true
source = ["notebook"]

[tool.mypy]
files = "notebook"
python_version = "3.9"
strict = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
warn_unreachable = true

[tool.ruff]
line-length = 100

[tool.ruff.format]
docstring-code-format = true

[tool.ruff.lint]
extend-select = [
  "B",           # flake8-bugbear
  "I",           # isort
  "ARG",         # flake8-unused-arguments
  "C4",          # flake8-comprehensions
  "EM",          # flake8-errmsg
  "ICN",         # flake8-import-conventions
  "G",           # flake8-logging-format
  "PGH",         # pygrep-hooks
  "PIE",         # flake8-pie
  "PL",          # pylint
  "PTH",         # flake8-use-pathlib
  "PT",          # flake8-pytest-style
  "RET",         # flake8-return
  "RUF",         # Ruff-specific
  "SIM",         # flake8-simplify
  "T20",         # flake8-print
  "UP",          # pyupgrade
  "YTT",         # flake8-2020
  "EXE",         # flake8-executable
  "PYI",         # flake8-pyi
  "S",           # flake8-bandit
]
ignore = [
  "PLR",    # Design related pylint codes
  "C408", "C416",  # Unnecessary `dict` call (rewrite as a literal)
  "RUF012",   # Mutable class attributes should be annotated with `typing.ClassVar`
]

[tool.ruff.lint.per-file-ignores]
# S101 Use of `assert` detected
# F841 Local variable `foo` is assigned to but never used
"tests/*" = ["S101", "F841", "ARG", "PTH"]
"docs/source/conf.py" = ["PTH"]
"ui-tests/test/jupyter_server_config.py" = ["F821"]
"*.ipynb" = ["E402", "B018", "E501", "T201", "RET"]

[tool.interrogate]
ignore-init-module=true
ignore-private=true
ignore-semiprivate=true
ignore-property-decorators=true
ignore-nested-functions=true
ignore-nested-classes=true
fail-under=100
exclude = ["tests", "ui-tests", "docs", "node_modules", "setup.py"]

[tool.repo-review]
ignore = ["GH102", "PC180", "PC111"]
