Skip to content

Commit a8f3841

Browse files
authored
Update ruff config (#23)
1 parent 04c4fcd commit a8f3841

4 files changed

Lines changed: 49 additions & 21 deletions

File tree

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ repos:
2121
- id: trailing-whitespace
2222

2323
- repo: https://github.com/python-jsonschema/check-jsonschema
24-
rev: 0.27.2
24+
rev: 0.27.3
2525
hooks:
2626
- id: check-github-workflows
2727

@@ -66,7 +66,7 @@ repos:
6666
additional_dependencies: ["traitlets>=5.13"]
6767

6868
- repo: https://github.com/astral-sh/ruff-pre-commit
69-
rev: v0.1.6
69+
rev: v0.1.7
7070
hooks:
7171
- id: ruff
7272
types_or: [python, jupyter]

comm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def _get_comm_manager() -> CommManager:
4848
4949
This method is intended to be replaced if needed (if you want to manage multiple CommManagers).
5050
"""
51-
global _comm_manager
51+
global _comm_manager # noqa: PLW0603
5252

5353
if _comm_manager is None:
5454
_comm_manager = CommManager()

comm/base_comm.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,22 @@ def __init__(
7070

7171
def publish_msg(
7272
self,
73-
msg_type: str,
74-
data: MaybeDict = None,
75-
metadata: MaybeDict = None,
76-
buffers: BuffersType = None,
77-
**keys: t.Any,
73+
msg_type: str, # noqa: ARG002
74+
data: MaybeDict = None, # noqa: ARG002
75+
metadata: MaybeDict = None, # noqa: ARG002
76+
buffers: BuffersType = None, # noqa: ARG002
77+
**keys: t.Any, # noqa: ARG002
7878
) -> None:
79-
raise NotImplementedError("publish_msg Comm method is not implemented")
79+
msg = "publish_msg Comm method is not implemented"
80+
raise NotImplementedError(msg)
8081

8182
def __del__(self) -> None:
8283
"""trigger close on gc"""
8384
self.close(deleting=True)
8485

8586
# publishing messages
8687

87-
def open( # noqa: A003
88+
def open(
8889
self, data: MaybeDict = None, metadata: MaybeDict = None, buffers: BuffersType = None
8990
) -> None:
9091
"""Open the frontend-side version of this comm"""
@@ -93,7 +94,8 @@ def open( # noqa: A003
9394
data = self._open_data
9495
comm_manager = comm.get_comm_manager()
9596
if comm_manager is None:
96-
raise RuntimeError("Comms cannot be opened without a comm_manager.")
97+
msg = "Comms cannot be opened without a comm_manager." # type:ignore[unreachable]
98+
raise RuntimeError(msg)
9799

98100
comm_manager.register_comm(self)
99101
try:
@@ -211,7 +213,7 @@ def register_target(self, target_name: str, f: CommTargetCallback | str) -> None
211213

212214
self.targets[target_name] = t.cast(CommTargetCallback, f)
213215

214-
def unregister_target(self, target_name: str, f: CommTargetCallback) -> CommTargetCallback:
216+
def unregister_target(self, target_name: str, f: CommTargetCallback) -> CommTargetCallback: # noqa: ARG002
215217
"""Unregister a callable registered with register_target"""
216218
return self.targets.pop(target_name)
217219

@@ -245,7 +247,7 @@ def get_comm(self, comm_id: str) -> BaseComm | None:
245247

246248
# Message handlers
247249

248-
def comm_open(self, stream: ZMQStream, ident: str, msg: MessageType) -> None:
250+
def comm_open(self, stream: ZMQStream, ident: str, msg: MessageType) -> None: # noqa: ARG002
249251
"""Handler for comm_open messages"""
250252
from comm import create_comm
251253

@@ -278,7 +280,7 @@ def comm_open(self, stream: ZMQStream, ident: str, msg: MessageType) -> None:
278280
exc_info=True,
279281
)
280282

281-
def comm_msg(self, stream: ZMQStream, ident: str, msg: MessageType) -> None:
283+
def comm_msg(self, stream: ZMQStream, ident: str, msg: MessageType) -> None: # noqa: ARG002
282284
"""Handler for comm_msg messages"""
283285
content = msg["content"]
284286
comm_id = content["comm_id"]
@@ -291,7 +293,7 @@ def comm_msg(self, stream: ZMQStream, ident: str, msg: MessageType) -> None:
291293
except Exception:
292294
logger.error("Exception in comm_msg for %s", comm_id, exc_info=True)
293295

294-
def comm_close(self, stream: ZMQStream, ident: str, msg: MessageType) -> None:
296+
def comm_close(self, stream: ZMQStream, ident: str, msg: MessageType) -> None: # noqa: ARG002
295297
"""Handler for comm_close messages"""
296298
content = msg["content"]
297299
comm_id = content["comm_id"]

pyproject.toml

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,33 @@ warn_unreachable = true
8686
line-length = 100
8787

8888
[tool.ruff.lint]
89-
select = [
90-
"A", "B", "C", "E", "F", "I", "N", "Q", "RUF", "S", "T",
91-
"UP", "W", "YTT",
89+
extend-select = [
90+
"B", # flake8-bugbear
91+
"I", # isort
92+
"ARG", # flake8-unused-arguments
93+
"C4", # flake8-comprehensions
94+
"EM", # flake8-errmsg
95+
"ICN", # flake8-import-conventions
96+
"G", # flake8-logging-format
97+
"PGH", # pygrep-hooks
98+
"PIE", # flake8-pie
99+
"PL", # pylint
100+
"PTH", # flake8-use-pathlib
101+
"PT", # flake8-pytest-style
102+
"RET", # flake8-return
103+
"RUF", # Ruff-specific
104+
"SIM", # flake8-simplify
105+
"T20", # flake8-print
106+
"UP", # pyupgrade
107+
"YTT", # flake8-2020
108+
"EXE", # flake8-executable
109+
"PYI", # flake8-pyi
110+
"S", # flake8-bandit
92111
]
93112
ignore = [
113+
"PLR", # Design related pylint codes
114+
"S101", # Use of `assert` detected
115+
"G201" # Logging `.exception(...)` should be used instead
94116
]
95117
unfixable = [
96118
# Don't touch print statements
@@ -100,8 +122,12 @@ unfixable = [
100122
]
101123

102124
[tool.ruff.lint.per-file-ignores]
103-
# S101 Use of `assert` detected
104-
"tests/*" = ["S101"]
125+
"tests/*" = []
126+
127+
[tool.ruff.lint.flake8-pytest-style]
128+
fixture-parentheses = false
129+
mark-parentheses = false
130+
parametrize-names-type = "csv"
105131

106132
[tool.repo-review]
107-
ignore = ["PY007", "PP308", "PY004", "GH102", "MY101", "RTD100"]
133+
ignore = ["PP308", "PY004", "GH102", "MY101", "RTD100"]

0 commit comments

Comments
 (0)