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

Adopt sp-repo-review #58

Merged
merged 3 commits into from
Sep 9, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Run Linters
run: |
- name: Run Linters
run: |
hatch run typing:test
hatch run lint:style
pipx run interrogate -v .
Expand Down
36 changes: 34 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ci:
autoupdate_schedule: monthly
autoupdate_commit_msg: "chore: update pre-commit hooks"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down Expand Up @@ -29,13 +30,44 @@ repos:
hooks:
- id: mdformat

- repo: https://github.com/psf/black
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.2"
hooks:
- id: prettier
types_or: [yaml, html, json]

- repo: https://github.com/adamchainz/blacken-docs
rev: "1.16.0"
hooks:
- id: blacken-docs
additional_dependencies: [black==23.7.0]

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.7.0
hooks:
- id: black

- repo: https://github.com/codespell-project/codespell
rev: "v2.2.5"
hooks:
- id: codespell
args: ["-L", "sur,nd"]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: "v1.10.0"
hooks:
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.287
hooks:
- id: ruff
args: ["--fix"]
args: ["--fix", "--show-fixes"]

- repo: https://github.com/scientific-python/cookie
rev: "2023.08.23"
hooks:
- id: sp-repo-review
additional_dependencies: ["repo-review[cli]"]
8 changes: 6 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ version: 2
sphinx:
configuration: docs/conf.py

# Optionally set the version of Python and requirements required to build your docs
build:
os: ubuntu-22.04
tools:
python: "3.11"

# Handle requirements required to build your docs
python:
version: 3.7
install:
- method: pip
path: .
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
]

try:
import enchant # type:ignore # noqa
import enchant # type:ignore[import] # noqa

extensions += ["sphinxcontrib.spelling"]
except ImportError:
Expand Down
34 changes: 20 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ docs = [
]
client = [
"jupyter_client>=7.4.0",
"nbformat>=5.3",
"ipykernel>=6.14"
]
server = [
"jupyter_server>=1.21",
"jupyter_client>=7.4.0",
"nbformat>=5.3",
"pytest-jupyter[client]",
"ipykernel>=6.14"
]
test = [
"pytest-timeout"
Expand Down Expand Up @@ -89,7 +91,7 @@ nowarn = "test -W default {args}"

[tool.hatch.envs.typing]
features = ["test", "server", "client"]
dependencies = ["mypy>=0.990"]
dependencies = ["mypy>=1.5.1"]
[tool.hatch.envs.typing.scripts]
test = "mypy --install-types --non-interactive {args:.}"

Expand All @@ -116,7 +118,13 @@ fmt = [
post-version-spec = "dev"

[tool.pytest.ini_options]
addopts = "-raXs --durations 10 --color=yes --doctest-modules"
minversion = "6.0"
xfail_strict = true
log_cli_level = "info"
addopts = [
"-raXs", "--durations=10", "--color=yes", "--doctest-modules",
"--showlocals", "--strict-markers", "--strict-config"
]
testpaths = [
"tests"
]
Expand Down Expand Up @@ -149,18 +157,13 @@ relative_files = true
source = ["pytest_jupyter"]

[tool.mypy]
check_untyped_defs = true
disallow_incomplete_defs = true
no_implicit_optional = true
pretty = true
show_error_context = true
files = "pytest_jupyter"
python_version = "3.8"
strict = true
show_error_codes = true
strict_equality = true
warn_unused_configs = true
warn_unused_ignores = true
warn_redundant_casts = true
explicit_package_bases = true
namespace_packages = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
disable_error_code = ["no-untyped-def"]
warn_unreachable = true

[tool.black]
line-length = 100
Expand Down Expand Up @@ -216,3 +219,6 @@ ignore-nested-functions=true
ignore-nested-classes=true
fail-under=100
exclude = ["docs", "tests"]

[tool.repo-review]
ignore = ["PY007", "PP308", "GH102", "PC140"]
14 changes: 12 additions & 2 deletions pytest_jupyter/echo_kernel.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
"""A simple echo kernel."""
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from __future__ import annotations

import logging
import typing

# mypy: disable-error-code="no-untyped-call"
from ipykernel.kernelapp import IPKernelApp
from ipykernel.kernelbase import Kernel

Expand All @@ -23,8 +26,15 @@ class EchoKernel(Kernel):
banner = "Echo kernel - as useful as a parrot"

def do_execute(
self, code, silent, store_history=True, user_expressions=None, allow_stdin=False
):
self,
code: str,
silent: bool,
store_history=True,
user_expressions: typing.Any = None,
allow_stdin=False,
*,
cell_id: str | None = None,
) -> dict[str, typing.Any]:
"""Execute code on the kernel."""
if not silent:
stream_content = {"name": "stdout", "text": code}
Expand Down
5 changes: 3 additions & 2 deletions pytest_jupyter/jupyter_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import json
import os
import sys
import typing
from pathlib import Path

import jupyter_core
Expand All @@ -16,7 +17,7 @@
import resource
except ImportError:
# Windows
resource = None # type: ignore
resource = None # type:ignore[assignment]


# Handle resource limit
Expand Down Expand Up @@ -52,7 +53,7 @@ def io_loop(jp_asyncio_loop):
"""Override the io_loop for pytest_tornasync. This is a no-op
if tornado is not installed."""

async def get_tornado_loop():
async def get_tornado_loop() -> typing.Any:
"""Asynchronously get a tornado loop."""
try:
from tornado.ioloop import IOLoop
Expand Down
Loading