Skip to content

Commit 3b9dc6d

Browse files
[E721] mix
1 parent d1d4918 commit 3b9dc6d

File tree

8 files changed

+30
-30
lines changed

8 files changed

+30
-30
lines changed

src/exceptions.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ def __init__(
2727
error: typing.Optional[T_ERR_DATA] = None,
2828
):
2929
assert message is None or type(message) is str
30-
assert command is None or type(command) in [str, list] # noqa: E721
30+
assert command is None or type(command) in [str, list]
3131
assert exit_code is None or type(exit_code) is int
32-
assert out is None or type(out) in [str, bytes] # noqa: E721
33-
assert error is None or type(error) in [str, bytes] # noqa: E721
32+
assert out is None or type(out) in [str, bytes]
33+
assert error is None or type(error) in [str, bytes]
3434

3535
super().__init__(message)
3636

@@ -71,7 +71,7 @@ def description(self) -> typing.Optional[str]:
7171

7272
@property
7373
def command(self) -> typing.Optional[T_CMD]:
74-
assert self._command is None or type(self._command) in [str, list] # noqa: E721
74+
assert self._command is None or type(self._command) in [str, list]
7575
return self._command
7676

7777
@property
@@ -81,12 +81,12 @@ def exit_code(self) -> typing.Optional[int]:
8181

8282
@property
8383
def out(self) -> typing.Optional[T_OUT_DATA]:
84-
assert self._out is None or type(self._out) in [str, bytes] # noqa: E721
84+
assert self._out is None or type(self._out) in [str, bytes]
8585
return self._out
8686

8787
@property
8888
def error(self) -> typing.Optional[T_ERR_DATA]:
89-
assert self._error is None or type(self._error) in [str, bytes] # noqa: E721
89+
assert self._error is None or type(self._error) in [str, bytes]
9090
return self._error
9191

9292
def __repr__(self) -> str:

src/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def PrepareProcessInput(input, encoding):
4343
if not input:
4444
return None
4545

46-
if type(input) == str: # noqa: E721
46+
if type(input) is str:
4747
if encoding is None:
4848
return input.encode(__class__.GetDefaultEncoding())
4949

src/local_ops.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ def get_single_instance() -> OsOperations:
6666
assert __class__.sm_single_instance_guard is not None
6767

6868
if __class__.sm_single_instance is not None:
69-
assert type(__class__.sm_single_instance) == __class__ # noqa: E721
69+
assert type(__class__.sm_single_instance) is __class__
7070
return __class__.sm_single_instance
7171

7272
with __class__.sm_single_instance_guard:
7373
if __class__.sm_single_instance is None:
7474
__class__.sm_single_instance = __class__()
7575
assert __class__.sm_single_instance is not None
76-
assert type(__class__.sm_single_instance) == __class__ # noqa: E721
76+
assert type(__class__.sm_single_instance) is __class__
7777
return __class__.sm_single_instance
7878

7979
def get_platform(self) -> str:
@@ -164,7 +164,7 @@ def _run_command__generic(
164164
if not get_process:
165165
input_prepared = Helpers.PrepareProcessInput(input, encoding) # throw
166166

167-
assert input_prepared is None or (type(input_prepared) == bytes) # noqa: E721
167+
assert input_prepared is None or type(input_prepared) is bytes
168168

169169
extParams: typing.Dict[str, str] = dict()
170170

@@ -334,7 +334,7 @@ def rmdirs(self, path, ignore_errors=True, attempts=3, delay=1):
334334
assert type(path) is str
335335
assert type(ignore_errors) is bool
336336
assert type(attempts) is int
337-
assert type(delay) == int or type(delay) == float # noqa: E721
337+
assert type(delay) is int or type(delay) is float
338338
assert attempts > 0
339339
assert delay >= 0
340340

@@ -576,7 +576,7 @@ def remove_file(self, filename):
576576
def kill(self, pid: int, signal: typing.Union[int, os_signal.Signals]):
577577
# Kill the process
578578
assert type(pid) is int
579-
assert type(signal) == int or type(signal) == os_signal.Signals # noqa: E721 E501
579+
assert type(signal) is int or type(signal) is os_signal.Signals
580580
os.kill(pid, signal)
581581

582582
def get_pid(self):

src/os_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def remove_file(self, filename):
134134
def kill(self, pid: int, signal: typing.Union[int, os_signal.Signals]):
135135
# Kill the process
136136
assert type(pid) is int
137-
assert type(signal) == int or type(signal) == os_signal.Signals # noqa: E721 E501
137+
assert type(signal) is int or type(signal) is os_signal.Signals
138138
raise NotImplementedError()
139139

140140
def get_pid(self):

src/raise_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def _TranslateDataIntoString(data):
4040
if data is None:
4141
return ""
4242

43-
if type(data) == bytes: # noqa: E721
43+
if type(data) is bytes:
4444
return __class__._TranslateDataIntoString__FromBinary(data)
4545

4646
return str(data)

src/remote_ops.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def exec_command(
121121
if not get_process:
122122
input_prepared = Helpers.PrepareProcessInput(input, encoding) # throw
123123

124-
assert input_prepared is None or (type(input_prepared) == bytes) # noqa: E721
124+
assert input_prepared is None or type(input_prepared) is bytes
125125

126126
cmds = []
127127

@@ -664,7 +664,7 @@ def remove_file(self, filename):
664664
def kill(self, pid: int, signal: typing.Union[int, os_signal.Signals]):
665665
# Kill the process
666666
assert type(pid) is int
667-
assert type(signal) == int or type(signal) == os_signal.Signals # noqa: E721 E501
667+
assert type(signal) is int or type(signal) is os_signal.Signals
668668
assert int(signal) == signal
669669
cmd = "kill -{} {}".format(int(signal), pid)
670670
return self.exec_command(cmd, encoding=get_default_encoding())
@@ -792,9 +792,9 @@ def _build_cmdline(cmd, exec_env: typing.Dict = None) -> str:
792792

793793
@staticmethod
794794
def _ensure_cmdline(cmd) -> typing.List[str]:
795-
if type(cmd) == str: # noqa: E721
795+
if type(cmd) is str:
796796
cmd_s = cmd
797-
elif type(cmd) == list: # noqa: E721
797+
elif type(cmd) is list:
798798
cmd_s = subprocess.list2cmdline(cmd)
799799
else:
800800
raise ValueError("Invalid 'cmd' argument type - {0}".format(type(cmd).__name__))

tests/test_os_ops_common.py

Lines changed: 10 additions & 10 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
@@ -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))
@@ -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)