[psutil] Add cache_clear to psutil.process_iter typing#14803
[psutil] Add cache_clear to psutil.process_iter typing#14803srittau merged 3 commits intopython:mainfrom emmanuel-ferdman:main
cache_clear to psutil.process_iter typing#14803Conversation
Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
This comment has been minimized.
This comment has been minimized.
srittau
left a comment
There was a problem hiding this comment.
Thanks, looks mostly good, a few specific notes below.
Generally regarding tests, we try to use a "less is more" approach in typeshed (as opposed to your typical unit tests in other projects), as the tests are fairly expensive, but are also often just repeating the type annotations, and many typical problems are already caught by tools like stubtest.
In this specific PR, it definitely makes sense to test that process_iter is still a callable, and that the clear_method() function exists as an attribute and is callable, but we don't need to the different argument permutations of process_iter(), and the last test just seems redundant with prior tests.
Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
PR Summary
This PR adds typing support for the
cache_clearmethod ofpsutil.process_iter. The fix replaces the function declaration with a_ProcessIterCallableProtocol that defines both the original callable signature and the newcache_clear()method, resolving mypy errors when accessingpsutil.process_iter.cache_clear()while maintaining full backward compatibility with existing code.Closes #14281.