Skip to content

Commit

Permalink
some pylint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Jan 11, 2025
1 parent de778ff commit ed1d425
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
8 changes: 2 additions & 6 deletions psutil/_pslinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -2005,12 +2005,8 @@ def get_blocks(lines, current_block):
if fields[0].startswith(b'VmFlags:'):
# see issue #369
continue
else:
msg = (
"don't know how to interpret line"
f" {line!r}"
)
raise ValueError(msg) from None
msg = f"don't know how to interpret line {line!r}"
raise ValueError(msg) from None
yield (current_block.pop(), data)

data = self._read_smaps_file()
Expand Down
2 changes: 1 addition & 1 deletion psutil/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2007,7 +2007,7 @@ def copyload_shared_lib(suffix=""):
FreeLibrary.argtypes = [wintypes.HMODULE]
ret = FreeLibrary(cfile._handle)
if ret == 0:
WinError()
raise WinError()
safe_rmpath(dst)


Expand Down
6 changes: 3 additions & 3 deletions psutil/tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -1178,8 +1178,8 @@ def test_parents(self):

def test_children(self):
parent = psutil.Process()
assert parent.children() == []
assert parent.children(recursive=True) == []
assert not parent.children()
assert not parent.children(recursive=True)
# On Windows we set the flag to 0 in order to cancel out the
# CREATE_NO_WINDOW flag (enabled by default) which creates
# an extra "conhost.exe" child.
Expand All @@ -1202,7 +1202,7 @@ def test_children_recursive(self):
# children() to recursively find it.
child.terminate()
child.wait()
assert parent.children(recursive=True) == []
assert not parent.children(recursive=True)

def test_children_duplicates(self):
# find the process which has the highest number of children
Expand Down
8 changes: 4 additions & 4 deletions psutil/tests/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_emulate_nsp(self):
'psutil.Process.as_dict',
side_effect=psutil.NoSuchProcess(os.getpid()),
):
assert list(psutil.process_iter(attrs=["cpu_times"])) == []
assert not list(psutil.process_iter(attrs=["cpu_times"]))
psutil.process_iter.cache_clear() # repeat test without cache

def test_emulate_access_denied(self):
Expand Down Expand Up @@ -151,9 +151,9 @@ def callback(p):
gone, alive = psutil.wait_procs(procs, timeout=0.01, callback=callback)

assert time.time() - t < 0.5
assert gone == []
assert not gone
assert len(alive) == 3
assert pids == []
assert not pids
for p in alive:
assert not hasattr(p, 'returncode')

Expand Down Expand Up @@ -243,7 +243,7 @@ def test_boot_time(self):
)
def test_users(self):
users = psutil.users()
assert users != []
assert users
for user in users:
with self.subTest(user=user):
assert user.name
Expand Down
4 changes: 1 addition & 3 deletions psutil/tests/test_testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,7 @@ def test_tcp_socketpair(self):
def test_unix_socketpair(self):
p = psutil.Process()
num_fds = p.num_fds()
assert (
filter_proc_net_connections(p.net_connections(kind='unix')) == []
)
assert not filter_proc_net_connections(p.net_connections(kind='unix'))
name = self.get_testfn()
server, client = unix_socketpair(name)
try:
Expand Down

0 comments on commit ed1d425

Please sign in to comment.