Skip to content
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
6 changes: 3 additions & 3 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.19.2
rev: 0.21.0
hooks:
- id: check-github-workflows

Expand All @@ -31,12 +31,12 @@ repos:
- id: mdformat

- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.236
rev: v0.0.243
hooks:
- id: ruff
args: ["--fix"]
2 changes: 1 addition & 1 deletion ipykernel/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def murmur2_x86(data, seed):

val = length & 0x03
k = 0
if val == 3: # noqa
if val == 3:
k = (ord(data[rounded_end + 2]) & 0xFF) << 16
if val in [2, 3]:
k |= (ord(data[rounded_end + 1]) & 0xFF) << 8
Expand Down
1 change: 0 additions & 1 deletion ipykernel/inprocess/tests/test_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def kc():


def test_with_cell_id(kc):

with patch_cell_id():
kc.execute("1+1")

Expand Down
1 change: 0 additions & 1 deletion ipykernel/iostream.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,6 @@ def write(self, string: str) -> Optional[int]: # type:ignore[override]
msg = "I/O operation on closed file"
raise ValueError(msg)
else:

is_child = not self._is_master_process()
# only touch the buffer in the IO thread to avoid races
with self._buffer_lock:
Expand Down
5 changes: 2 additions & 3 deletions ipykernel/ipkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
try:
from IPython.core.interactiveshell import _asyncio_runner # type:ignore[attr-defined]
except ImportError:
_asyncio_runner = None
_asyncio_runner = None # type:ignore

try:
from IPython.core.completer import provisionalcompleter as _provisionalcompleter
Expand Down Expand Up @@ -366,7 +366,6 @@ async def run_cell(*args, **kwargs):

with_cell_id = _accepts_cell_id(shell.run_cell)
try:

# default case: runner is asyncio and asyncio is already running
# TODO: this should check every case for "are we inside the runner",
# not just asyncio
Expand Down Expand Up @@ -626,7 +625,7 @@ def do_apply(self, content, bufs, msg_id, reply_metadata):
try:
from ipyparallel.serialize import serialize_object, unpack_apply_message
except ImportError:
from .serialize import serialize_object, unpack_apply_message # type:ignore
from .serialize import serialize_object, unpack_apply_message

shell = self.shell
try:
Expand Down
2 changes: 1 addition & 1 deletion ipykernel/jsonutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def json_clean(obj): # pragma: no cover
it simply sanitizes it so that there will be no encoding errors later.

"""
if int(JUPYTER_CLIENT_MAJOR_VERSION) >= 7: # noqa
if int(JUPYTER_CLIENT_MAJOR_VERSION) >= 7:
return obj

# types that are 'atomic' and ok in json as-is.
Expand Down
5 changes: 1 addition & 4 deletions ipykernel/kernelapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,11 +471,8 @@ def init_io(self):
sys.stderr.flush()
sys.stderr = outstream_factory(self.session, self.iopub_thread, "stderr", echo=e_stderr)
if hasattr(sys.stderr, "_original_stdstream_copy"):

for handler in self.log.handlers:
if isinstance(handler, StreamHandler) and (
handler.stream.buffer.fileno() == 2 # noqa
):
if isinstance(handler, StreamHandler) and (handler.stream.buffer.fileno() == 2):
self.log.debug("Seeing logger to stderr, rerouting to raw filedescriptor.")

handler.stream = TextIOWrapper(
Expand Down
2 changes: 1 addition & 1 deletion ipykernel/kernelbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ async def usage_request(self, stream, ident, parent):
cpu_percent = psutil.cpu_percent()
# https://psutil.readthedocs.io/en/latest/index.html?highlight=cpu#psutil.cpu_percent
# The first time cpu_percent is called it will return a meaningless 0.0 value which you are supposed to ignore.
if cpu_percent is not None and cpu_percent != 0.0: # noqa
if cpu_percent is not None and cpu_percent != 0.0:
reply_content["host_cpu_percent"] = cpu_percent
reply_content["cpu_count"] = psutil.cpu_count(logical=True)
reply_content["host_virtual_memory"] = dict(psutil.virtual_memory()._asdict())
Expand Down
2 changes: 1 addition & 1 deletion ipykernel/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def unpack_apply_message(bufs, g=None, copy=True):
"""unpack f,args,kwargs from buffers packed by pack_apply_message()
Returns: original f,args,kwargs"""
bufs = list(bufs) # allow us to pop
assert len(bufs) >= 2, "not enough buffers!" # noqa
assert len(bufs) >= 2, "not enough buffers!"
pf = bufs.pop(0)
f = uncan(pickle.loads(pf), g)
pinfo = bufs.pop(0)
Expand Down
4 changes: 0 additions & 4 deletions ipykernel/tests/test_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def test_sys_path_profile_dir():
def test_subprocess_print():
"""printing from forked mp.Process"""
with new_kernel() as kc:

_check_master(kc, expected=True)
flush_channels(kc)
np = 5
Expand Down Expand Up @@ -146,7 +145,6 @@ def test_subprocess_print():
def test_subprocess_noprint():
"""mp.Process without print doesn't trigger iostream mp_mode"""
with kernel() as kc:

np = 5
code = "\n".join(
[
Expand Down Expand Up @@ -174,7 +172,6 @@ def test_subprocess_noprint():
def test_subprocess_error():
"""error in mp.Process doesn't crash"""
with new_kernel() as kc:

code = "\n".join(
[
"import multiprocessing as mp",
Expand Down Expand Up @@ -459,7 +456,6 @@ def test_interrupt_during_pdb_set_trace():


def test_control_thread_priority():

N = 5
with new_kernel() as kc:
msg_id = kc.execute("pass")
Expand Down
1 change: 0 additions & 1 deletion ipykernel/tests/test_kernelspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def test_write_kernel_spec_path():


def test_install_kernelspec():

path = tempfile.mkdtemp()
try:
InstallIPythonKernelSpecApp.launch_instance(argv=["--prefix", path])
Expand Down
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies = [
"tornado>=6.1",
"matplotlib-inline>=0.1",
'appnope;platform_system=="Darwin"',
"pyzmq>=17",
"pyzmq>=20",
"psutil",
"packaging",
]
Expand Down Expand Up @@ -116,7 +116,7 @@ dependencies = ["mypy>=0.990"]
test = "mypy --install-types --non-interactive {args:.}"

[tool.hatch.envs.lint]
dependencies = ["black==22.12.0", "mdformat>0.7", "ruff==0.0.236"]
dependencies = ["black==23.1.0", "mdformat>0.7", "ruff==0.0.243"]
detached = true
[tool.hatch.envs.lint.scripts]
style = [
Expand Down Expand Up @@ -227,7 +227,6 @@ select = [
"N",
"PLC",
"PLE",
"PLR",
"PLW",
"Q",
"RUF",
Expand Down Expand Up @@ -274,6 +273,8 @@ ignore = [
"N801",
# SIM105 Use `contextlib.suppress(ValueError)` instead of try-except-pass
"SIM105",
# S110 `try`-`except`-`pass` detected
"S110",
]
unfixable = [
# Don't touch print statements
Expand Down