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

Update ruff config #146

Merged
merged 1 commit into from
Dec 14, 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 .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.2
rev: 0.27.3
hooks:
- id: check-github-workflows

Expand Down Expand Up @@ -67,7 +67,7 @@ repos:
additional_dependencies: ["jupyter_client"]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
rev: v0.1.8
hooks:
- id: ruff
types_or: [python, jupyter]
Expand Down
38 changes: 19 additions & 19 deletions jupyter_kernel_test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_kernel_info(self) -> None:
)
self.assertTrue(reply["content"]["language_info"]["file_extension"].startswith("."))

def execute_helper( # noqa
def execute_helper(
self,
code: str,
timeout: int = TIMEOUT,
Expand All @@ -97,7 +97,7 @@ def execute_helper( # noqa
if msg["msg_type"] == "status":
self.assertEqual(msg["content"]["execution_state"], "idle")
break
elif msg["msg_type"] == "execute_input":
if msg["msg_type"] == "execute_input":
self.assertEqual(msg["content"]["code"], code)
continue
output_msgs.append(msg)
Expand All @@ -108,7 +108,7 @@ def execute_helper( # noqa

def test_execute_stdout(self) -> None:
if not self.code_hello_world:
raise SkipTest("No code hello world") # noqa
raise SkipTest("No code hello world")

self.flush_channels()
reply, output_msgs = self.execute_helper(code=self.code_hello_world)
Expand All @@ -129,7 +129,7 @@ def test_execute_stdout(self) -> None:

def test_execute_stderr(self) -> None:
if not self.code_stderr:
raise SkipTest("No code stderr") # noqa
raise SkipTest("No code stderr")

self.flush_channels()
reply, output_msgs = self.execute_helper(code=self.code_stderr)
Expand All @@ -156,7 +156,7 @@ def get_non_kernel_info_reply(self, timeout: float | None = None) -> dict[str, A

def test_completion(self) -> None:
if not self.completion_samples:
raise SkipTest("No completion samples") # noqa
raise SkipTest("No completion samples")

for sample in self.completion_samples:
with self.subTest(text=sample["text"]):
Expand Down Expand Up @@ -184,7 +184,7 @@ def test_is_complete(self) -> None:
if not (
self.complete_code_samples or self.incomplete_code_samples or self.invalid_code_samples
):
raise SkipTest("Not testing is_complete") # noqa
raise SkipTest("Not testing is_complete")

self.flush_channels()

Expand All @@ -204,7 +204,7 @@ def test_is_complete(self) -> None:

def test_pager(self) -> None:
if not self.code_page_something:
raise SkipTest("No code page something") # noqa
raise SkipTest("No code page something")

self.flush_channels()

Expand All @@ -220,7 +220,7 @@ def test_pager(self) -> None:

def test_error(self) -> None:
if not self.code_generate_error:
raise SkipTest("No code generate error") # noqa
raise SkipTest("No code generate error")

self.flush_channels()

Expand All @@ -233,7 +233,7 @@ def test_error(self) -> None:

def test_execute_result(self) -> None:
if not self.code_execute_result:
raise SkipTest("No code execute result") # noqa
raise SkipTest("No code execute result")

for sample in self.code_execute_result:
with self.subTest(code=sample["code"]):
Expand Down Expand Up @@ -263,7 +263,7 @@ def test_execute_result(self) -> None:

def test_display_data(self) -> None:
if not self.code_display_data:
raise SkipTest("No code display data") # noqa
raise SkipTest("No code display data")

for sample in self.code_display_data:
with self.subTest(code=sample["code"]):
Expand Down Expand Up @@ -307,7 +307,7 @@ def history_helper(

def test_history(self) -> None:
if not self.code_execute_result:
raise SkipTest("No code execute result") # noqa
raise SkipTest("No code execute result")

codes = [s["code"] for s in self.code_execute_result]
_ = [s.get("result", "") for s in self.code_execute_result]
Expand All @@ -317,7 +317,7 @@ def test_history(self) -> None:

with self.subTest(hist_access_type="tail"):
if "tail" not in self.supported_history_operations:
raise SkipTest("History tail not supported") # noqa
raise SkipTest("History tail not supported")
reply = self.history_helper(codes, output=False, raw=True, hist_access_type="tail", n=n)
self.assertEqual(len(reply["content"]["history"]), n)
self.assertEqual(len(reply["content"]["history"][0]), 3)
Expand All @@ -332,9 +332,9 @@ def test_history(self) -> None:

with self.subTest(hist_access_type="range"):
if "range" not in self.supported_history_operations:
raise SkipTest("History range not supported") # noqa
raise SkipTest("History range not supported")
if session is None:
raise SkipTest("No session") # noqa
raise SkipTest("No session")
reply = self.history_helper(
codes,
output=False,
Expand All @@ -350,9 +350,9 @@ def test_history(self) -> None:

with self.subTest(hist_access_type="search"):
if not self.code_history_pattern:
raise SkipTest("No code history pattern") # noqa
raise SkipTest("No code history pattern")
if "search" not in self.supported_history_operations:
raise SkipTest("History search not supported") # noqa
raise SkipTest("History search not supported")
with self.subTest(subsearch="normal"):
reply = self.history_helper(
codes,
Expand Down Expand Up @@ -387,7 +387,7 @@ def test_history(self) -> None:

def test_inspect(self) -> None:
if not self.code_inspect_sample:
raise SkipTest("No code inspect sample") # noqa
raise SkipTest("No code inspect sample")

self.flush_channels()
msg_id = self.kc.inspect(self.code_inspect_sample)
Expand All @@ -402,7 +402,7 @@ def test_inspect(self) -> None:

def test_clear_output(self) -> None:
if not self.code_clear_output:
raise SkipTest("No code clear output") # noqa
raise SkipTest("No code clear output")

self.flush_channels()
reply, output_msgs = self.execute_helper(code=self.code_clear_output)
Expand Down Expand Up @@ -440,7 +440,7 @@ def tearDownClass(cls) -> None:

def test_recv_iopub_welcome_msg(self) -> None:
if not self.support_iopub_welcome:
raise SkipTest("Iopub welcome messages are not supported") # noqa
raise SkipTest("Iopub welcome messages are not supported")

self.kc.start_channels()
while True:
Expand Down
2 changes: 1 addition & 1 deletion jupyter_kernel_test/msgspec_v5.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def get_abort_reply_validator(version_minor: int) -> Draft4Validator:
}


def validate_message( # noqa: C901,PLR0912
def validate_message(
msg: dict[str, Any] | None, msg_type: str | None = None, parent_id: str | None = None
) -> None:
msg_structure_validator.validate(msg)
Expand Down
34 changes: 26 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,34 @@ warn_unreachable = true
line-length = 100

[tool.ruff.lint]
select = [
"A", "B", "C", "DTZ", "E", "EM", "F", "I", "ICN", "N",
"PLC", "PLE", "PLR", "PLW", "Q", "RUF", "S", "SIM", "T", "TID", "UP",
"W", "YTT",
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 = [
# RUF012 Mutable class attributes should be annotated with `typing.ClassVar`
"RUF012",
# S101 Use of `assert` detected
"S101",
"PLR", # Design related pylint codes
"RUF012", # Mutable class attributes should be annotated with
"S101", # Use of `assert` detected
"PT009" # Use a regular `assert` instead of unittest-style"
]
unfixable = [
# Don't touch print statements
Expand Down
2 changes: 1 addition & 1 deletion test_irkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def setUpClass(cls):
try:
cls.km, cls.kc = jkt.start_new_kernel(kernel_name=cls.kernel_name)
except NoSuchKernel:
raise unittest.SkipTest("No ir kernel installed") from None # noqa
raise unittest.SkipTest("No ir kernel installed") from None

language_name = "R"

Expand Down
2 changes: 1 addition & 1 deletion test_xeus_cling.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setUpClass(cls):
try:
cls.km, cls.kc = jkt.start_new_kernel(kernel_name=cls.kernel_name)
except NoSuchKernel:
raise unittest.SkipTest("Xeus-Cling Kernel not installed") from None # noqa
raise unittest.SkipTest("Xeus-Cling Kernel not installed") from None

language_name = "c++"

Expand Down
Loading