Skip to content

Commit c8b32c1

Browse files
Final cleanup of E721 suppression (#347)
* [E721] ... is tuple * [E721] mix * [E721] ... is PostgresNodeService * [E721] mix * [E721] conftest
1 parent c73e5f6 commit c8b32c1

File tree

19 files changed

+123
-123
lines changed

19 files changed

+123
-123
lines changed

src/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def message(self) -> str:
192192

193193
for f, lines in self._files or []:
194194
assert type(f) is str
195-
assert type(lines) in [str, bytes] # noqa: E721
195+
assert type(lines) in [str, bytes]
196196
msg.append(u'{}\n----\n{}\n'.format(f, lines))
197197

198198
return six.text_type('\n').join(msg)

src/impl/port_manager__generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def reserve_port(self) -> int:
4848
t = None
4949

5050
for port in sampled_ports:
51-
assert type(port) is int # noqa: E721
51+
assert type(port) is int
5252
assert port not in self._reserved_ports
5353
assert port in self._available_ports
5454

src/node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2244,7 +2244,7 @@ def _table_checksum__use_cn(
22442244

22452245
row = cursor.fetchone()
22462246
assert row is not None
2247-
assert type(row) in [list, tuple] # noqa: E721
2247+
assert type(row) in [list, tuple]
22482248
assert len(row) == 1
22492249
v = row[0]
22502250
sum += int(v if v is not None else 0)

tests/conftest.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class TestStartupData__Helper:
8282
# --------------------------------------------------------------------
8383
@staticmethod
8484
def GetStartTS() -> datetime.datetime:
85-
assert type(__class__.sm_StartTS) == datetime.datetime # noqa: E721
85+
assert type(__class__.sm_StartTS) is datetime.datetime
8686
return __class__.sm_StartTS
8787

8888
# --------------------------------------------------------------------
@@ -113,7 +113,7 @@ def CalcCurrentTestWorkerSignature() -> str:
113113
assert type(currentPID) is int
114114

115115
startTS = __class__.sm_StartTS
116-
assert type(startTS) == datetime.datetime # noqa: E721
116+
assert type(startTS) is datetime.datetime
117117

118118
result = "pytest-{0:04d}{1:02d}{2:02d}_{3:02d}{4:02d}{5:02d}".format(
119119
startTS.year,
@@ -405,8 +405,8 @@ def helper__makereport__setup(
405405
assert outcome is not None
406406
# it may be pytest.Function or _pytest.unittest.TestCaseFunction
407407
assert isinstance(item, pytest.Function)
408-
assert type(call) == pytest.CallInfo # noqa: E721
409-
assert type(outcome) == T_PLUGGY_RESULT # noqa: E721
408+
assert type(call) is pytest.CallInfo
409+
assert type(outcome) is T_PLUGGY_RESULT
410410

411411
C_LINE1 = "******************************************************"
412412

@@ -416,7 +416,7 @@ def helper__makereport__setup(
416416

417417
rep: pytest.TestReport = outcome.get_result()
418418
assert rep is not None
419-
assert type(rep) == pytest.TestReport # noqa: E721
419+
assert type(rep) is pytest.TestReport
420420

421421
if rep.outcome == "skipped":
422422
TEST_PROCESS_STATS.incrementNotExecutedTestCount()
@@ -474,8 +474,8 @@ def helper__makereport__call(
474474
assert outcome is not None
475475
# it may be pytest.Function or _pytest.unittest.TestCaseFunction
476476
assert isinstance(item, pytest.Function)
477-
assert type(call) == pytest.CallInfo # noqa: E721
478-
assert type(outcome) == T_PLUGGY_RESULT # noqa: E721
477+
assert type(call) is pytest.CallInfo
478+
assert type(outcome) is T_PLUGGY_RESULT
479479

480480
# --------
481481
item_error_msg_count1 = item.stash.get(g_error_msg_count_key, 0)
@@ -496,7 +496,7 @@ def helper__makereport__call(
496496
# --------
497497
rep = outcome.get_result()
498498
assert rep is not None
499-
assert type(rep) == pytest.TestReport # noqa: E721
499+
assert type(rep) is pytest.TestReport
500500

501501
# --------
502502
testID = helper__build_test_id(item)
@@ -505,12 +505,12 @@ def helper__makereport__call(
505505
assert call.start <= call.stop
506506

507507
startDT = datetime.datetime.fromtimestamp(call.start)
508-
assert type(startDT) == datetime.datetime # noqa: E721
508+
assert type(startDT) is datetime.datetime
509509
stopDT = datetime.datetime.fromtimestamp(call.stop)
510-
assert type(stopDT) == datetime.datetime # noqa: E721
510+
assert type(stopDT) is datetime.datetime
511511

512512
testDurration = stopDT - startDT
513-
assert type(testDurration) == datetime.timedelta # noqa: E721
513+
assert type(testDurration) is datetime.timedelta
514514

515515
# --------
516516
exitStatus = None
@@ -519,7 +519,7 @@ def helper__makereport__call(
519519
assert call.excinfo is not None # research
520520
assert call.excinfo.value is not None # research
521521

522-
if type(call.excinfo.value) == _pytest.outcomes.Skipped: # noqa: E721
522+
if type(call.excinfo.value) is _pytest.outcomes.Skipped:
523523
assert not hasattr(rep, "wasxfail")
524524

525525
exitStatus = ExitStatusNames.SKIPPED
@@ -528,7 +528,7 @@ def helper__makereport__call(
528528

529529
TEST_PROCESS_STATS.incrementSkippedTestCount()
530530

531-
elif type(call.excinfo.value) == _pytest.outcomes.XFailed: # noqa: E721 E501
531+
elif type(call.excinfo.value) is _pytest.outcomes.XFailed:
532532
exitStatus = ExitStatusNames.XFAILED
533533
reasonText = str(call.excinfo.value)
534534
reasonMsgTempl = "XFAIL REASON: {0}"
@@ -544,7 +544,7 @@ def helper__makereport__call(
544544
reasonText = rep.wasxfail
545545
reasonMsgTempl = "XFAIL REASON: {0}"
546546

547-
if type(call.excinfo.value) == SIGNAL_EXCEPTION: # noqa: E721
547+
if type(call.excinfo.value) is SIGNAL_EXCEPTION:
548548
pass
549549
else:
550550
logging.error(call.excinfo.value)
@@ -563,7 +563,7 @@ def helper__makereport__call(
563563
assert call.excinfo is not None
564564
assert call.excinfo.value is not None
565565

566-
if type(call.excinfo.value) == SIGNAL_EXCEPTION: # noqa: E721
566+
if type(call.excinfo.value) is SIGNAL_EXCEPTION:
567567
assert item_error_msg_count > 0
568568
pass
569569
else:
@@ -614,8 +614,8 @@ def helper__makereport__call(
614614
pass
615615

616616
# --------
617-
assert type(TEST_PROCESS_STATS.cTotalDuration) == datetime.timedelta # noqa: E721
618-
assert type(testDurration) == datetime.timedelta # noqa: E721
617+
assert type(TEST_PROCESS_STATS.cTotalDuration) is datetime.timedelta
618+
assert type(testDurration) is datetime.timedelta
619619

620620
TEST_PROCESS_STATS.cTotalDuration += testDurration
621621

@@ -656,11 +656,11 @@ def pytest_runtest_makereport(item: pytest.Function, call: pytest.CallInfo):
656656
assert call is not None
657657
# it may be pytest.Function or _pytest.unittest.TestCaseFunction
658658
assert isinstance(item, pytest.Function)
659-
assert type(call) == pytest.CallInfo # noqa: E721
659+
assert type(call) is pytest.CallInfo
660660

661661
outcome = yield
662662
assert outcome is not None
663-
assert type(outcome) == T_PLUGGY_RESULT # noqa: E721
663+
assert type(outcome) is T_PLUGGY_RESULT
664664

665665
assert type(call.when) is str
666666

@@ -808,7 +808,7 @@ def pytest_pyfunc_call(pyfuncitem: pytest.Function):
808808

809809
try:
810810
with LogWrapper2() as logWrapper:
811-
assert type(logWrapper) == LogWrapper2 # noqa: E721
811+
assert type(logWrapper) is LogWrapper2
812812
assert logWrapper._old_method is not None
813813
assert type(logWrapper._err_counter) is int
814814
assert logWrapper._err_counter == 0
@@ -821,7 +821,7 @@ def pytest_pyfunc_call(pyfuncitem: pytest.Function):
821821
r = yield
822822

823823
assert r is not None
824-
assert type(r) == T_PLUGGY_RESULT # noqa: E721
824+
assert type(r) is T_PLUGGY_RESULT
825825

826826
assert logWrapper._old_method is not None
827827
assert type(logWrapper._err_counter) is int
@@ -918,7 +918,7 @@ def helper__print_test_list2(tests: typing.List[T_TUPLE__str_int]) -> None:
918918
nTest = 0
919919

920920
for t in tests:
921-
assert type(t) == tuple # noqa: E721
921+
assert type(t) is tuple
922922
assert len(t) == 2
923923
assert type(t[0]) is str
924924
assert type(t[1]) is int
@@ -943,15 +943,15 @@ def pytest_sessionfinish():
943943
global g_worker_log_is_created # noqa: F824
944944

945945
assert g_test_process_kind is not None
946-
assert type(g_test_process_kind) == T_TEST_PROCESS_KIND # noqa: E721
946+
assert type(g_test_process_kind) is T_TEST_PROCESS_KIND
947947

948948
if g_test_process_kind == T_TEST_PROCESS_KIND.Master:
949949
return
950950

951951
assert g_test_process_kind == T_TEST_PROCESS_KIND.Worker
952952

953953
assert g_test_process_mode is not None
954-
assert type(g_test_process_mode) == T_TEST_PROCESS_MODE # noqa: E721
954+
assert type(g_test_process_mode) is T_TEST_PROCESS_MODE
955955

956956
if g_test_process_mode == T_TEST_PROCESS_MODE.Collect:
957957
return
@@ -1050,7 +1050,7 @@ def LOCAL__print_test_list2(
10501050
logging.info(" UNEXPECTED : {0}".format(TEST_PROCESS_STATS.cUnexpectedTests))
10511051
logging.info("")
10521052

1053-
assert type(TEST_PROCESS_STATS.cTotalDuration) == datetime.timedelta # noqa: E721
1053+
assert type(TEST_PROCESS_STATS.cTotalDuration) is datetime.timedelta
10541054

10551055
LOCAL__print_line1_with_header("TIME")
10561056
logging.info("")
@@ -1136,8 +1136,8 @@ def pytest_configure(config: pytest.Config) -> None:
11361136
g_test_process_mode = helper__detect_test_process_mode(config)
11371137
g_test_process_kind = helper__detect_test_process_kind(config)
11381138

1139-
assert type(g_test_process_kind) == T_TEST_PROCESS_KIND # noqa: E721
1140-
assert type(g_test_process_mode) == T_TEST_PROCESS_MODE # noqa: E721
1139+
assert type(g_test_process_kind) is T_TEST_PROCESS_KIND
1140+
assert type(g_test_process_mode) is T_TEST_PROCESS_MODE
11411141

11421142
if g_test_process_kind == T_TEST_PROCESS_KIND.Master:
11431143
pass

tests/helpers/pg_node_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def __str__(self) -> str:
5959

6060
def __repr__(self) -> str:
6161
# It must be overrided!
62-
assert type(self) == __class__ # noqa: E721
62+
assert type(self) is __class__
6363
r = "{}({}, {})".format(
6464
__class__.__name__,
6565
repr(self._data_dir),
@@ -100,7 +100,7 @@ def message(self) -> str:
100100

101101
for f, lines in self._files or []:
102102
assert type(f) is str
103-
assert type(lines) in [str, bytes] # noqa: E721
103+
assert type(lines) in [str, bytes]
104104
msg_parts.append(u'{}\n----\n{}\n'.format(f, lines))
105105

106106
return "\n".join(msg_parts)
@@ -157,7 +157,7 @@ def wait_for_running_state(
157157
timeout: T_WAIT_TIME,
158158
):
159159
assert type(node) is PostgresNode
160-
assert type(node_log_reader) == PostgresNodeLogReader # noqa: E721
160+
assert type(node_log_reader) is PostgresNodeLogReader
161161
assert type(timeout) in [int, float]
162162
assert node_log_reader._node is node
163163
assert timeout > 0
@@ -176,7 +176,7 @@ def wait_for_running_state(
176176
assert type(blocks) is list
177177

178178
for block in blocks:
179-
assert type(block) == PostgresNodeLogReader.LogDataBlock # noqa: E721
179+
assert type(block) is PostgresNodeLogReader.LogDataBlock
180180

181181
if 'Is another postmaster already running on port' in block.data:
182182
raise __class__.PortConflictNodeException(node.data_dir, node.port)

tests/test_os_ops_common.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_create_clone(self, os_ops: OsOperations):
6161
clone = os_ops.create_clone()
6262
assert clone is not None
6363
assert clone is not os_ops
64-
assert type(clone) == type(os_ops) # noqa: E721
64+
assert type(clone) is type(os_ops)
6565

6666
def test_exec_command_success(self, os_ops: OsOperations):
6767
"""
@@ -759,11 +759,11 @@ def __init__(self, sign, source, cp_rw, cp_truncate, cp_binary, cp_data, result)
759759
)
760760
def write_data001(self, request):
761761
assert isinstance(request, pytest.FixtureRequest)
762-
assert type(request.param) == __class__.tagWriteData001 # noqa: E721
762+
assert type(request.param) is __class__.tagWriteData001
763763
return request.param
764764

765765
def test_write(self, write_data001: tagWriteData001, os_ops: OsOperations):
766-
assert type(write_data001) == __class__.tagWriteData001 # noqa: E721
766+
assert type(write_data001) is __class__.tagWriteData001
767767
assert isinstance(os_ops, OsOperations)
768768

769769
mode = "w+b" if write_data001.call_param__binary else "w+"
@@ -847,7 +847,7 @@ def test_is_port_free__false(self, os_ops: OsOperations):
847847

848848
def LOCAL_server(s: socket.socket):
849849
assert s is not None
850-
assert type(s) == socket.socket # noqa: E721
850+
assert type(s) is socket.socket
851851

852852
try:
853853
while True:
@@ -873,7 +873,7 @@ def LOCAL_server(s: socket.socket):
873873

874874
s.listen(10)
875875

876-
assert type(th) == threading.Thread # noqa: E721
876+
assert type(th) is threading.Thread
877877
th.start()
878878

879879
try:
@@ -964,7 +964,7 @@ def data001(self, request: pytest.FixtureRequest) -> tagData_OS_OPS__NUMS:
964964
return request.param
965965

966966
def test_mkdir__mt(self, data001: tagData_OS_OPS__NUMS):
967-
assert type(data001) == __class__.tagData_OS_OPS__NUMS # noqa: E721
967+
assert type(data001) is __class__.tagData_OS_OPS__NUMS
968968

969969
N_WORKERS = 4
970970
N_NUMBERS = data001.nums
@@ -1003,7 +1003,7 @@ def LOCAL_WORKER(os_ops: OsOperations,
10031003

10041004
def LOG_INFO(template: str, *args) -> None:
10051005
assert type(template) is str
1006-
assert type(args) == tuple # noqa: E721
1006+
assert type(args) is tuple
10071007

10081008
msg = template.format(*args)
10091009
assert type(msg) is str
@@ -1226,14 +1226,14 @@ class tadWorkerData:
12261226
)
12271227
def kill_signal_id(self, request: pytest.FixtureRequest) -> T_KILL_SIGNAL_DESCR:
12281228
assert isinstance(request, pytest.FixtureRequest)
1229-
assert type(request.param) == tuple # noqa: E721
1229+
assert type(request.param) is tuple
12301230
return request.param
12311231

12321232
def test_kill_signal(
12331233
self,
12341234
kill_signal_id: T_KILL_SIGNAL_DESCR,
12351235
):
1236-
assert type(kill_signal_id) == tuple # noqa: E721
1236+
assert type(kill_signal_id) is tuple
12371237
assert "{}".format(kill_signal_id[1]) == kill_signal_id[2]
12381238
assert "{}".format(int(kill_signal_id[1])) == kill_signal_id[2]
12391239

@@ -1246,7 +1246,7 @@ def test_kill(
12461246
Test listdir for listing directory contents.
12471247
"""
12481248
assert isinstance(os_ops, OsOperations)
1249-
assert type(kill_signal_id) == tuple # noqa: E721
1249+
assert type(kill_signal_id) is tuple
12501250

12511251
cmd = [
12521252
sys.executable,
@@ -1261,7 +1261,7 @@ def test_kill(
12611261
)
12621262

12631263
assert proc is not None
1264-
assert type(proc) == subprocess.Popen # noqa: E721
1264+
assert type(proc) is subprocess.Popen
12651265
proc_pid = proc.pid
12661266
assert type(proc_pid) is int
12671267
logging.info("Test process pid is {}".format(proc_pid))
@@ -1315,7 +1315,7 @@ def test_kill__unk_pid(
13151315
Test listdir for listing directory contents.
13161316
"""
13171317
assert isinstance(os_ops, OsOperations)
1318-
assert type(kill_signal_id) == tuple # noqa: E721
1318+
assert type(kill_signal_id) is tuple
13191319

13201320
cmd = [
13211321
sys.executable,
@@ -1332,7 +1332,7 @@ def test_kill__unk_pid(
13321332
)
13331333

13341334
assert proc is not None
1335-
assert type(proc) == subprocess.Popen # noqa: E721
1335+
assert type(proc) is subprocess.Popen
13361336
proc_pid = proc.pid
13371337
assert type(proc_pid) is int
13381338
logging.info("Test process pid is {}".format(proc_pid))
@@ -1387,10 +1387,10 @@ def test_kill__unk_pid(
13871387
logging.info("Our exception has type [{}]".format(type(x.value).__name__))
13881388

13891389
if type(os_ops).__name__ == "LocalOsOperations":
1390-
assert type(x.value) == ProcessLookupError # noqa: E721
1390+
assert type(x.value) is ProcessLookupError
13911391
assert "No such process" in str(x.value)
13921392
elif type(os_ops).__name__ == "RemoteOsOperations":
1393-
assert type(x.value) == ExecUtilException # noqa: E721
1393+
assert type(x.value) is ExecUtilException
13941394
assert "No such process" in str(x.value)
13951395
else:
13961396
RuntimeError("Unknown os_ops type: {}".format(type(os_ops).__name__))

tests/test_os_ops_remote.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ def test_rmdirs__try_to_delete_file(self, os_ops: OsOperations):
3232
os_ops.rmdirs(path, ignore_errors=False)
3333

3434
assert os.path.exists(path)
35-
assert type(x.value) == ExecUtilException # noqa: E721
36-
assert type(x.value.description) == str # noqa: E721
35+
assert type(x.value) is ExecUtilException
36+
assert type(x.value.description) is str
3737
assert x.value.description == "Utility exited with non-zero code (20). Error: `cannot remove '" + path + "': it is not a directory`"
3838
assert x.value.message.startswith(x.value.description)
3939
assert type(x.value.error) is str

0 commit comments

Comments
 (0)