Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up lint and move tests out of source #299

Merged
merged 8 commits into from Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 11 additions & 7 deletions .github/workflows/main.yml
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Run Linters
run: |
hatch run typing:test
hatch run lint:style
hatch run lint:build
pipx run interrogate -v .
pipx run doc8 --max-line-length=200

Expand All @@ -41,13 +41,17 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
exclude:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.8", "3.11"]
include:
- os: windows-latest
python-version: 3.8
- os: windows-latest
python-version: 3.9
python-version: "3.9"
- os: ubuntu-latest
python-version: "pypy-3.8"
- os: ubuntu-latest
python-version: "3.12"
- os: macos-latest
python-version: "3.10"
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Expand Up @@ -57,6 +57,21 @@ repos:
- id: rst-directive-colons
- id: rst-inline-touching-normal

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.6.1"
hooks:
- id: mypy
files: "^nbclient"
stages: [manual]
args: ["--install-types", "--non-interactive"]
additional_dependencies:
[
"traitlets>=5.13",
"jupyter_core>=5.3.2",
"jupyter_client",
"nbformat",
]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3
hooks:
Expand Down
1 change: 0 additions & 1 deletion docs/index.rst
Expand Up @@ -64,7 +64,6 @@ this documentation section will help you.
:caption: Table of Contents

reference/index.rst
reference/nbclient.tests.rst

Indices and tables
------------------
Expand Down
4 changes: 0 additions & 4 deletions docs/reference/nbclient.rst
Expand Up @@ -4,10 +4,6 @@ nbclient package
Subpackages
-----------

.. toctree::

nbclient.tests

Submodules
----------

Expand Down
38 changes: 0 additions & 38 deletions docs/reference/nbclient.tests.rst

This file was deleted.

2 changes: 1 addition & 1 deletion nbclient/cli.py
Expand Up @@ -47,7 +47,7 @@ class NbClientApp(JupyterApp):
flags = nbclient_flags

description = "An application used to execute notebook files (*.ipynb)"
notebooks = List([], help="Path of notebooks to convert").tag(config=True)
notebooks = List(Unicode(), help="Path of notebooks to convert").tag(config=True)
timeout = Integer(
None,
allow_none=True,
Expand Down
4 changes: 2 additions & 2 deletions nbclient/client.py
Expand Up @@ -494,9 +494,9 @@ def create_kernel_manager(self) -> KernelManager:
self.kernel_name = kn

if not self.kernel_name:
self.km = self.kernel_manager_class(config=self.config) # type:ignore[operator]
self.km = self.kernel_manager_class(config=self.config)
else:
self.km = self.kernel_manager_class(kernel_name=self.kernel_name, config=self.config) # type:ignore[operator]
self.km = self.kernel_manager_class(kernel_name=self.kernel_name, config=self.config)
assert self.km is not None
return self.km

Expand Down
43 changes: 17 additions & 26 deletions pyproject.toml
Expand Up @@ -84,6 +84,7 @@ path = "nbclient/_version.py"
[tool.hatch.build.targets.sdist]
include = [
"/nbclient",
"/tests"
]

[tool.hatch.envs.docs]
Expand All @@ -104,40 +105,27 @@ dependencies = ["coverage[toml]", "pytest-cov"]
test = "python -m pytest -vv --cov nbclient --cov-branch --cov-report term-missing:skip-covered {args}"
nowarn = "test -W default {args}"

[tool.hatch.envs.typing]
features = ["test"]
dependencies = ["mypy~=1.6", "traitlets>=5.11.2", "jupyter_core>=5.3.2"]
[tool.hatch.envs.typing.scripts]
test = "mypy --install-types --non-interactive {args}"

[tool.hatch.envs.lint]
dependencies = [
"mdformat>0.7",
"mdformat-gfm>=0.3.5",
"ruff==0.1.3"
]
detached = true
dependencies = ["pre-commit"]
[tool.hatch.envs.lint.scripts]
style = [
"ruff {args:.}",
"ruff format {args:.}",
"mdformat --check {args:docs *.md}"
]
fmt = [
"ruff --fix {args:.}",
"ruff format {args:.}",
"mdformat {args:docs *.md}"
]
build = "pre-commit run --all-files ruff"

[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.pytest.ini_options]
minversion = "6.0"
xfail_strict = true
log_cli_level = "info"
addopts = [
"-raXs", "--durations=10", "--color=yes", "--doctest-modules",
"-ra", "--durations=10", "--color=yes", "--doctest-modules",
"--showlocals", "--strict-markers", "--strict-config"
]
testpaths = ["nbclient/tests"]
testpaths = ["tests"]
filterwarnings= [
# Fail on warnings
"error",
Expand All @@ -146,7 +134,10 @@ filterwarnings= [
"module:There is no current event loop:DeprecationWarning",
"module:unclosed event loop:ResourceWarning",
"module:Unclosed socket <zmq:ResourceWarning",
"module:zmq.eventloop.ioloop is deprecated:DeprecationWarning",
"module:subprocess .* is still running:ResourceWarning",
"module:Unclosed context <zmq:ResourceWarning",
"module:datetime.datetime.utc:DeprecationWarning",
]
asyncio_mode = "auto"

Expand Down Expand Up @@ -204,7 +195,7 @@ ignore = [

[tool.ruff.lint.per-file-ignores]
# S101 Use of `assert` detected
"nbclient/tests/*" = ["S101"]
"tests/*" = ["S101"]
"nbclient/client.py" = ["S101"]

[tool.interrogate]
Expand All @@ -215,7 +206,7 @@ ignore-property-decorators=true
ignore-nested-functions=true
ignore-nested-classes=true
fail-under=100
exclude = ["nbclient/tests", "docs"]
exclude = ["tests", "docs"]

[tool.repo-review]
ignore = ["PY005", "PY007", "PP308", "GH102", "PC140"]
ignore = ["PY005", "PY007", "GH102"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
3 changes: 3 additions & 0 deletions nbclient/tests/test_client.py → tests/test_client.py
Expand Up @@ -352,6 +352,7 @@ def test_run_all_notebooks(input_name, opts):
assert_notebooks_equal(input_nb, output_nb)


@flaky
def test_parallel_notebooks(capfd, tmpdir):
"""Two notebooks should be able to be run simultaneously without problems.

Expand All @@ -377,6 +378,7 @@ def test_parallel_notebooks(capfd, tmpdir):
assert filter_messages_on_error_output(captured.err) == ""


@flaky
@pytest.mark.skipif(os.name == "nt", reason="warns about event loop on Windows")
def test_many_parallel_notebooks(capfd):
"""Ensure that when many IPython kernels are run in parallel, nothing awful happens.
Expand Down Expand Up @@ -404,6 +406,7 @@ def test_many_parallel_notebooks(capfd):
assert filter_messages_on_error_output(captured.err) == ""


@flaky
def test_async_parallel_notebooks(capfd, tmpdir):
"""Two notebooks should be able to be run simultaneously without problems.

Expand Down
File renamed without changes.