Skip to content

Commit 6a138c8

Browse files
authored
Merge pull request #5221 from grondo/pre-commit-t
ci: fix pre-commit config to lint python files in testsuite
2 parents 337be43 + d6bd926 commit 6a138c8

37 files changed

+175
-410
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
files: '^(src/bindings/python/flux|src/cmd|t/.*\\.py)'
2-
exclude: "^(src/bindings/python/_flux/|src/bindings/python/flux/utils/)"
1+
files: '^(src/bindings/python/flux|src/cmd|t/python/.*\.py|t/scripts/.*\.py)'
2+
exclude: "^(src/bindings/python/_flux/|src/bindings/python/flux/utils/|t/python/tap)"
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
55
rev: v4.0.1

t/python/sideflux.py

Lines changed: 0 additions & 231 deletions
This file was deleted.

t/python/subflux.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env python3
2-
31
###############################################################
42
# Copyright 2014 Lawrence Livermore National Security, LLC
53
# (c.f. AUTHORS, NOTICE.LLNS, COPYING)
@@ -10,10 +8,10 @@
108
# SPDX-License-Identifier: LGPL-3.0
119
###############################################################
1210

11+
import argparse
1312
import os
14-
import sys
1513
import subprocess
16-
import argparse
14+
import sys
1715

1816
script_dir = os.path.dirname(os.path.abspath(__file__))
1917

t/python/t0001-handle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
# SPDX-License-Identifier: LGPL-3.0
1111
###############################################################
1212

13-
import unittest
1413
import syslog
14+
import unittest
1515

1616
import flux
17-
from subflux import rerun_under_flux, script_dir
17+
from subflux import rerun_under_flux
1818

1919

2020
def __flux_size():

t/python/t0002-wrapper.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
import unittest
1414

1515
import flux
16-
from flux.core.inner import ffi, raw
1716
import flux.wrapper
17+
from flux.core.inner import ffi, raw
1818
from subflux import rerun_under_flux
1919

2020

@@ -42,12 +42,12 @@ def test_null_handle_exception(self):
4242
f = flux.Flux()
4343
payload = {"seq": 1, "pad": "stuff"}
4444
future = f.rpc("broker.ping", payload)
45-
resp = future.get()
45+
future.get()
4646
future.pimpl.handle = None
4747
with self.assertRaisesRegex(
4848
ValueError, r"Attempting to call a cached, bound method.*NULL handle"
4949
):
50-
resp = future.get()
50+
future.get()
5151

5252
def test_automatic_unwrapping(self):
5353
flux.core.inner.raw.flux_log(flux.Flux("loop://"), 0, "stuff")

t/python/t0003-barrier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
# SPDX-License-Identifier: LGPL-3.0
1111
###############################################################
1212

13-
import unittest
1413
import multiprocessing as mp
14+
import unittest
1515

1616
import flux
1717
from subflux import rerun_under_flux

t/python/t0005-kvs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import flux
1616
import flux.kvs
17-
1817
from subflux import rerun_under_flux
1918

2019

@@ -39,7 +38,7 @@ def set_and_check_context(self, key, value, type):
3938
kd2 = flux.kvs.KVSDir(self.f)
4039
nv = kd2[key]
4140
if isinstance(value, bytes) and type is str:
42-
self.assertEqual(value.decode('utf-8'), nv)
41+
self.assertEqual(value.decode("utf-8"), nv)
4342
else:
4443
self.assertEqual(value, nv)
4544
if type is not None:

t/python/t0006-request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
# SPDX-License-Identifier: LGPL-3.0
1111
###############################################################
1212

13+
import errno
1314
import unittest
1415

15-
import errno
1616
import flux
1717
from subflux import rerun_under_flux
1818

t/python/t0007-watchers.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
# SPDX-License-Identifier: LGPL-3.0
1111
###############################################################
1212

13-
import unittest
14-
import os
1513
import gc
14+
import os
1615
import signal
16+
import unittest
17+
1718
import flux
1819
from subflux import rerun_under_flux
1920

@@ -67,8 +68,8 @@ def test_timer_callback_exception(self):
6768
def cb(x, y, z, w):
6869
raise RuntimeError("this is a test")
6970

70-
with self.f.timer_watcher_create(0.01, cb) as timer:
71-
with self.assertRaises(RuntimeError) as cm:
71+
with self.f.timer_watcher_create(0.01, cb):
72+
with self.assertRaises(RuntimeError):
7273
self.f.reactor_run()
7374

7475
def test_msg_watcher_unicode(self):
@@ -155,7 +156,7 @@ def raise_signal(handle, watcher, revents, args):
155156
# Create new Flux handle to avoid potential stale state in
156157
# self.f handle. (makes test unreliable)
157158
h = flux.Flux()
158-
with h.signal_watcher_create(signal.SIGUSR2, signal_cb) as watcher:
159+
with h.signal_watcher_create(signal.SIGUSR2, signal_cb):
159160
h.timer_watcher_create(0.05, raise_signal).start()
160161
with self.assertRaises(RuntimeError):
161162
rc = h.reactor_run()
@@ -231,7 +232,7 @@ def cb_abort(handle, watcher, revents, _args):
231232
self.f.timer_watcher_create(0.0, cb, repeat=0.05).start()
232233

233234
# Timeout/abort after 5s
234-
tw = self.f.timer_watcher_create(5.0, cb_abort).start()
235+
self.f.timer_watcher_create(5.0, cb_abort).start()
235236
self.f.reactor_run()
236237

237238
# callback should have been called 5 times, not less

t/python/t0009-security.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
try:
1919
from flux.security import SecurityContext
20-
except:
20+
except ModuleNotFoundError:
2121
print("1..0 # skip flux.security module not available")
2222
sys.exit(0)
2323

0 commit comments

Comments
 (0)