typeshed icon indicating copy to clipboard operation
typeshed copied to clipboard

psutil.process_iter.cache_clear not available

Open KennethNielsen opened this issue 5 months ago • 1 comments

A recent addition to psutil added a cache_clear callable to psutil.process_iter, which is not available with the latest version (7.0.0.20250601) of "types-psutil".

I wouldn't mind trying to provide a PR to fix this, but I'm wanted to hear whether it had any interest first.

Steps to reproduce

Write code like the following:

import psutil

psutil.process_iter.cache_clear()
for process in psutil.process_iter():
    print(process)

This should run just fine but mypy complains about cache_clear.

/home/kenneth/.config/JetBrains/PyCharm2024.3/scratches/scratch_12.py:3: error: "Callable[[list[str] | tuple[str, ...] | set[str] | frozenset[str] | None, Any], Iterator[Process]]" has no attribute "cache_clear"  [attr-defined]
Found 1 error in 1 file (checked 1 source file)

KennethNielsen avatar Jun 16 '25 10:06 KennethNielsen

Looks reasonable, feel free to send a PR!

This will involve typing process_util as an instance of a private callable type that also defines cache_clear.

brianschubert avatar Jun 16 '25 15:06 brianschubert