Skip to content

Commit ff78616

Browse files
authored
Update ruff and typings (#66)
1 parent e0e42e1 commit ff78616

File tree

10 files changed

+96
-90
lines changed

10 files changed

+96
-90
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ repos:
3131
- id: mdformat
3232

3333
- repo: https://github.com/pre-commit/mirrors-prettier
34-
rev: "v3.0.3"
34+
rev: "v3.1.0"
3535
hooks:
3636
- id: prettier
3737
types_or: [yaml, html, json]
@@ -49,7 +49,7 @@ repos:
4949
args: ["-L", "sur,nd"]
5050

5151
- repo: https://github.com/pre-commit/mirrors-mypy
52-
rev: "v1.6.1"
52+
rev: "v1.7.0"
5353
hooks:
5454
- id: mypy
5555
files: pytest_jupyter
@@ -71,7 +71,7 @@ repos:
7171
- id: rst-inline-touching-normal
7272

7373
- repo: https://github.com/astral-sh/ruff-pre-commit
74-
rev: v0.1.5
74+
rev: v0.1.6
7575
hooks:
7676
- id: ruff
7777
types_or: [python, jupyter]
@@ -80,7 +80,7 @@ repos:
8080
types_or: [python, jupyter]
8181

8282
- repo: https://github.com/scientific-python/cookie
83-
rev: "2023.10.27"
83+
rev: "2023.11.17"
8484
hooks:
8585
- id: sp-repo-review
8686
additional_dependencies: ["repo-review[cli]"]

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# -- Project information -----------------------------------------------------
1919

2020
project = "pytest-jupyter"
21-
copyright = "2020, Project Jupyter" # noqa
21+
copyright = "2020, Project Jupyter"
2222
author = "Project Jupyter"
2323

2424

@@ -33,7 +33,7 @@
3333
]
3434

3535
try:
36-
import enchant # type:ignore[import-not-found] # noqa
36+
import enchant # type:ignore[import-not-found] # noqa: F401
3737

3838
extensions += ["sphinxcontrib.spelling"]
3939
except ImportError:

pyproject.toml

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ source = ["pytest_jupyter"]
149149
files = "pytest_jupyter"
150150
python_version = "3.8"
151151
strict = true
152-
show_error_codes = true
153152
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
154153
disable_error_code = ["no-untyped-def"]
155154
warn_unreachable = true
@@ -158,25 +157,36 @@ warn_unreachable = true
158157
line-length = 100
159158

160159
[tool.ruff.lint]
161-
select = [
162-
"A", "B", "C", "DTZ", "E", "EM", "F", "FBT", "I", "ICN", "N",
163-
"PLC", "PLE", "PLR", "PLW", "Q", "RUF", "S", "SIM", "T", "TID", "UP",
164-
"W", "YTT",
160+
extend-select = [
161+
"B", # flake8-bugbear
162+
"I", # isort
163+
"ARG", # flake8-unused-arguments
164+
"C4", # flake8-comprehensions
165+
"EM", # flake8-errmsg
166+
"ICN", # flake8-import-conventions
167+
"G", # flake8-logging-format
168+
"PGH", # pygrep-hooks
169+
"PIE", # flake8-pie
170+
"PL", # pylint
171+
"PT", # flake8-pytest-style
172+
"PTH", # flake8-use-pathlib
173+
"RET", # flake8-return
174+
"RUF", # Ruff-specific
175+
"SIM", # flake8-simplify
176+
"T20", # flake8-print
177+
"UP", # pyupgrade
178+
"YTT", # flake8-2020
179+
"EXE", # flake8-executable
180+
"NPY", # NumPy specific rules
181+
"PD", # pandas-vet
182+
"PYI", # flake8-pyi
165183
]
166184
ignore = [
167-
# Q000 Single quotes found but double quotes preferred
168-
"Q000",
169-
# FBT001 Boolean positional arg in function definition
170-
"FBT001", "FBT002", "FBT003",
171-
# E501 Line too long (158 > 100 characters)
172-
"E501",
173-
# SIM105 Use `contextlib.suppress(...)`
174-
"SIM105",
175-
#PLR0913 Too many arguments to function call
176-
"PLR0913",
177-
# RUF012 Mutable class attributes should be annotated with `typing.ClassVar`
178-
"RUF012",
179-
]
185+
"PLR", # Design related pylint codes
186+
"SIM105", # Use `contextlib.suppress(...)`
187+
"RUF012", # Mutable class attributes should be annotated with
188+
"ARG001", # Unused function argument:
189+
]
180190
unfixable = [
181191
# Don't touch print statements
182192
"T201",
@@ -186,14 +196,9 @@ unfixable = [
186196

187197
[tool.ruff.lint.per-file-ignores]
188198
# B011 Do not call assert False since python -O removes these calls
189-
# F841 local variable 'foo' is assigned to but never used
190-
# C408 Unnecessary `dict` call
191-
# E402 Module level import not at top of file
192199
# T201 `print` found
193200
# B007 Loop control variable `i` not used within the loop body.
194-
# N802 Function name `assertIn` should be lowercase
195-
# S101 Use of `assert` detected
196-
"tests/*" = ["B011", "F841", "C408", "E402", "T201", "B007", "N802", "S101"]
201+
"tests/*" = ["B011", "C4", "T201", "B007", "PTH", "ARG"]
197202

198203
[tool.interrogate]
199204
ignore-init-module=true
@@ -204,6 +209,3 @@ ignore-nested-functions=true
204209
ignore-nested-classes=true
205210
fail-under=100
206211
exclude = ["docs", "tests"]
207-
208-
[tool.repo-review]
209-
ignore = ["PY007", "PP308", "GH102"]

pytest_jupyter/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
__all__ = ["__version__"]
55

66
from ._version import __version__
7-
from .jupyter_core import * # noqa
7+
from .jupyter_core import * # noqa: F403

pytest_jupyter/echo_kernel.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ class EchoKernel(Kernel):
2525
}
2626
banner = "Echo kernel - as useful as a parrot"
2727

28-
def do_execute(
28+
def do_execute( # type:ignore[override]
2929
self,
3030
code: str,
3131
silent: bool,
32-
store_history=True,
33-
user_expressions: typing.Any = None,
32+
store_history=True, # noqa: ARG002
33+
user_expressions: typing.Any = None, # noqa: ARG002
3434
allow_stdin=False,
3535
*,
36-
cell_id: str | None = None,
36+
cell_id: str | None = None, # noqa: ARG002
3737
) -> dict[str, typing.Any]:
3838
"""Execute code on the kernel."""
3939
if not silent:

pytest_jupyter/jupyter_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pytest
66

77
try:
8-
import ipykernel # noqa
8+
import ipykernel # noqa: F401
99
from jupyter_client.kernelspec import NATIVE_KERNEL_NAME
1010
from jupyter_client.manager import start_new_async_kernel
1111
except ImportError:
@@ -20,11 +20,11 @@
2020
)
2121

2222
# Bring in local plugins.
23-
from pytest_jupyter.jupyter_core import * # noqa
24-
from pytest_jupyter.pytest_tornasync import * # noqa
23+
from pytest_jupyter.jupyter_core import * # noqa: F403
24+
from pytest_jupyter.pytest_tornasync import * # noqa: F403
2525

2626

27-
@pytest.fixture
27+
@pytest.fixture()
2828
def jp_zmq_context():
2929
"""Get a zmq context."""
3030
import zmq
@@ -34,7 +34,7 @@ def jp_zmq_context():
3434
ctx.term()
3535

3636

37-
@pytest.fixture
37+
@pytest.fixture()
3838
def jp_start_kernel(jp_environ, jp_asyncio_loop):
3939
"""Get a function to a kernel and clean up resources when done."""
4040
kms = []

pytest_jupyter/jupyter_core.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
resource.setrlimit(resource.RLIMIT_NOFILE, (soft, hard))
3636

3737

38-
@pytest.fixture
38+
@pytest.fixture()
3939
def jp_asyncio_loop():
4040
"""Get an asyncio loop."""
4141
if os.name == "nt":
@@ -65,49 +65,49 @@ async def get_tornado_loop() -> typing.Any:
6565
return jp_asyncio_loop.run_until_complete(get_tornado_loop())
6666

6767

68-
@pytest.fixture
68+
@pytest.fixture()
6969
def jp_home_dir(tmp_path):
7070
"""Provides a temporary HOME directory value."""
7171
return mkdir(tmp_path, "home")
7272

7373

74-
@pytest.fixture
74+
@pytest.fixture()
7575
def jp_data_dir(tmp_path):
7676
"""Provides a temporary Jupyter data dir directory value."""
7777
return mkdir(tmp_path, "data")
7878

7979

80-
@pytest.fixture
80+
@pytest.fixture()
8181
def jp_config_dir(tmp_path):
8282
"""Provides a temporary Jupyter config dir directory value."""
8383
return mkdir(tmp_path, "config")
8484

8585

86-
@pytest.fixture
86+
@pytest.fixture()
8787
def jp_runtime_dir(tmp_path):
8888
"""Provides a temporary Jupyter runtime dir directory value."""
8989
return mkdir(tmp_path, "runtime")
9090

9191

92-
@pytest.fixture
92+
@pytest.fixture()
9393
def jp_system_jupyter_path(tmp_path):
9494
"""Provides a temporary Jupyter system path value."""
9595
return mkdir(tmp_path, "share", "jupyter")
9696

9797

98-
@pytest.fixture
98+
@pytest.fixture()
9999
def jp_env_jupyter_path(tmp_path):
100100
"""Provides a temporary Jupyter env system path value."""
101101
return mkdir(tmp_path, "env", "share", "jupyter")
102102

103103

104-
@pytest.fixture
104+
@pytest.fixture()
105105
def jp_system_config_path(tmp_path):
106106
"""Provides a temporary Jupyter config path value."""
107107
return mkdir(tmp_path, "etc", "jupyter")
108108

109109

110-
@pytest.fixture
110+
@pytest.fixture()
111111
def jp_env_config_path(tmp_path):
112112
"""Provides a temporary Jupyter env config path value."""
113113
return mkdir(tmp_path, "env", "etc", "jupyter")
@@ -119,7 +119,7 @@ def jp_kernel_dir(jp_data_dir):
119119
return mkdir(jp_data_dir, "kernels")
120120

121121

122-
@pytest.fixture
122+
@pytest.fixture()
123123
def echo_kernel_spec(jp_kernel_dir):
124124
"""Install a kernel spec for the echo kernel."""
125125
test_dir = Path(jp_kernel_dir) / "echo"
@@ -131,8 +131,8 @@ def echo_kernel_spec(jp_kernel_dir):
131131
return str(test_dir)
132132

133133

134-
@pytest.fixture
135-
def jp_environ(
134+
@pytest.fixture()
135+
def jp_environ( # noqa: PT004
136136
monkeypatch,
137137
tmp_path,
138138
jp_home_dir,

0 commit comments

Comments
 (0)