Skip to content

Commit 12e8214

Browse files
committed
update flake8 and pre-commit
1 parent e53203a commit 12e8214

18 files changed

+81
-34
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ jobs:
122122
- name: Install miniumum versions
123123
uses: jupyterlab/maintainer-tools/.github/actions/install-minimums@v1
124124
- name: Run the unit tests
125-
env: PYTHONWARNINGS=default
125+
env:
126+
PYTHONWARNINGS: default
126127
run: pytest -vv jupyter_client || pytest -vv jupyter_client --lf
127128

128129
test_prereleases:

.mailmap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ David Hirschfeld <[email protected]> dhirschfeld <david.hirschfeld
2626
David P. Sanders <[email protected]> David P. Sanders <[email protected]>
2727
David Warde-Farley <[email protected]> David Warde-Farley <>
2828
Doug Blank <[email protected]> Doug Blank <[email protected]>
29-
Eugene Van den Bulke <[email protected]> Eugene Van den Bulke <[email protected]>
29+
Eugene Van den Bulke <[email protected]> Eugene Van den Bulke <[email protected]>
3030
3131
3232

.pre-commit-config.yaml

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,55 @@
1+
ci:
2+
skip: [check-jsonschema]
3+
14
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v4.1.0
7+
hooks:
8+
- id: end-of-file-fixer
9+
- id: check-case-conflict
10+
- id: check-executables-have-shebangs
11+
- id: requirements-txt-fixer
12+
- id: check-added-large-files
13+
- id: check-case-conflict
14+
- id: check-toml
15+
- id: check-yaml
16+
- id: debug-statements
17+
- id: forbid-new-submodules
18+
- id: check-builtin-literals
19+
- id: trailing-whitespace
20+
221
- repo: https://github.com/asottile/reorder_python_imports
322
rev: v2.7.1
423
hooks:
524
- id: reorder-python-imports
25+
626
- repo: https://github.com/psf/black
727
rev: 22.1.0
828
hooks:
929
- id: black
1030
args: ["--line-length", "100"]
31+
1132
- repo: https://github.com/pre-commit/mirrors-prettier
1233
rev: v2.5.1
1334
hooks:
1435
- id: prettier
15-
- repo: https://gitlab.com/pycqa/flake8
16-
rev: "3.9.2"
36+
37+
- repo: https://github.com/pycqa/flake8
38+
rev: 4.0.1
1739
hooks:
1840
- id: flake8
19-
- repo: https://github.com/pre-commit/pre-commit-hooks
20-
rev: v4.1.0
41+
additional_dependencies:
42+
[
43+
"flake8-bugbear==20.1.4",
44+
"flake8-logging-format==0.6.0",
45+
"flake8-implicit-str-concat==0.2.0",
46+
]
47+
48+
- repo: https://github.com/sirosen/check-jsonschema
49+
rev: 0.14.1
2150
hooks:
22-
- id: end-of-file-fixer
23-
- id: check-case-conflict
24-
- id: check-executables-have-shebangs
25-
- id: requirements-txt-fixer
51+
- id: check-jsonschema
52+
name: "Check GitHub Workflows"
53+
files: ^\.github/workflows/
54+
types: [yaml]
55+
args: ["--schemafile", "https://json.schemastore.org/github-workflow"]

docs/messaging.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ kernel has dedicated sockets for the following functions:
7373
appropriately.
7474

7575
4. **Control**: This channel is identical to Shell, but operates on a separate
76-
socket to avoid queueing behind execution requests. The control channel is
76+
socket to avoid queueing behind execution requests. The control channel is
7777
used for shutdown and restart messages, as well as for debugging messages.
7878

7979
For a smoother user experience, we recommend running the control channel in
@@ -1176,7 +1176,7 @@ In order to support page reloading, or a client connecting at a later stage, Jup
11761176
],
11771177
'stoppedThreads' : list(int), # threads in which the debugger is currently in a stopped state
11781178
'richRendering' : bool, # whether the debugger supports rich rendering of variables
1179-
'exceptionPaths' : list(str), # exception names used to match leaves or nodes in a tree of exception
1179+
'exceptionPaths' : list(str), # exception names used to match leaves or nodes in a tree of exception
11801180
}
11811181
}
11821182

jupyter_client/connect.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def write_connection_file(
117117
+ int(hb_port <= 0)
118118
)
119119
if transport == "tcp":
120-
for i in range(ports_needed):
120+
for _ in range(ports_needed):
121121
sock = socket.socket()
122122
# struct.pack('ii', (0,0)) is 8 null bytes
123123
sock.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, b"\0" * 8)
@@ -129,7 +129,7 @@ def write_connection_file(
129129
ports.append(port)
130130
else:
131131
N = 1
132-
for i in range(ports_needed):
132+
for _ in range(ports_needed):
133133
while os.path.exists("%s-%s" % (ip, str(N))):
134134
N += 1
135135
ports.append(N)
@@ -450,7 +450,7 @@ def cleanup_connection_file(self) -> None:
450450
self._connection_file_written = False
451451
try:
452452
os.remove(self.connection_file)
453-
except (IOError, OSError, AttributeError):
453+
except (OSError, AttributeError):
454454
pass
455455

456456
def cleanup_ipc_files(self) -> None:
@@ -461,7 +461,7 @@ def cleanup_ipc_files(self) -> None:
461461
ipcfile = "%s-%i" % (self.ip, port)
462462
try:
463463
os.remove(ipcfile)
464-
except (IOError, OSError):
464+
except OSError:
465465
pass
466466

467467
def _record_random_port_names(self) -> None:

jupyter_client/kernelspec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def install_kernel_spec(
412412
def install_native_kernel_spec(self, user=False):
413413
"""DEPRECATED: Use ipykernel.kernelspec.install"""
414414
warnings.warn(
415-
"install_native_kernel_spec is deprecated." " Use ipykernel.kernelspec import install.",
415+
"install_native_kernel_spec is deprecated. Use ipykernel.kernelspec import install.",
416416
stacklevel=2,
417417
)
418418
from ipykernel.kernelspec import install

jupyter_client/launcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def launch_kernel(
157157
proc = Popen(cmd, **kwargs)
158158
except Exception as ex:
159159
try:
160-
msg = "Failed to run command:\n{}\n" " PATH={!r}\n" " with kwargs:\n{!r}\n"
160+
msg = "Failed to run command:\n{}\n PATH={!r}\n with kwargs:\n{!r}\n"
161161
# exclude environment variables,
162162
# which may contain access tokens and the like.
163163
without_env = {key: value for key, value in kwargs.items() if key != "env"}

jupyter_client/localinterfaces.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def _load_ips_ifconfig():
102102

103103
try:
104104
out = _get_output("ifconfig")
105-
except (IOError, OSError):
105+
except OSError:
106106
# no ifconfig, it's usually in /sbin and /sbin is not on everyone's PATH
107107
out = _get_output("/sbin/ifconfig")
108108

@@ -237,16 +237,16 @@ def _load_ips(suppress_exceptions=True):
237237
if os.name == "nt":
238238
try:
239239
return _load_ips_ipconfig()
240-
except (IOError, NoIPAddresses):
240+
except NoIPAddresses:
241241
pass
242242
else:
243243
try:
244244
return _load_ips_ip()
245-
except (IOError, OSError, NoIPAddresses):
245+
except NoIPAddresses:
246246
pass
247247
try:
248248
return _load_ips_ifconfig()
249-
except (IOError, OSError, NoIPAddresses):
249+
except NoIPAddresses:
250250
pass
251251

252252
# lowest priority, use gethostbyname

jupyter_client/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ async def _async_restart_kernel(self, now: bool = False, newports: bool = False,
519519
kernel.
520520
"""
521521
if self._launch_args is None:
522-
raise RuntimeError("Cannot restart the kernel. " "No previous call to 'start_kernel'.")
522+
raise RuntimeError("Cannot restart the kernel. No previous call to 'start_kernel'.")
523523

524524
# Stop currently running kernel.
525525
await ensure_async(self.shutdown_kernel(now=now, restart=True))

jupyter_client/provisioning/provisioner_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ async def get_provisioner_info(self) -> Dict[str, Any]:
185185
186186
NOTE: The superclass method must always be called first to ensure proper serialization.
187187
"""
188-
provisioner_info: Dict[str, Any] = dict()
188+
provisioner_info: Dict[str, Any] = {}
189189
provisioner_info['kernel_id'] = self.kernel_id
190190
provisioner_info['connection_info'] = self.connection_info
191191
return provisioner_info

0 commit comments

Comments
 (0)