mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-06 21:43:59 +08:00
[psutil] Add cache_clear to psutil.process_iter typing (#14803)
This commit is contained in:
@@ -8,3 +8,6 @@ psutil._pssunos
|
||||
|
||||
# Test utilities
|
||||
psutil.tests.*
|
||||
|
||||
# process_iter is enhanced with cache_clear method that's not detected by stubtest
|
||||
psutil.process_iter
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
"""Test cases for psutil.process_iter and its cache_clear method."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import psutil
|
||||
|
||||
# Test that process_iter can be called as a function
|
||||
for proc in psutil.process_iter():
|
||||
break
|
||||
|
||||
# Test that process_iter has cache_clear method
|
||||
psutil.process_iter.cache_clear()
|
||||
|
||||
# Test that cache_clear is callable
|
||||
clear_method = psutil.process_iter.cache_clear
|
||||
clear_method()
|
||||
@@ -2,7 +2,7 @@ import sys
|
||||
from _typeshed import Incomplete
|
||||
from collections.abc import Callable, Iterable, Iterator
|
||||
from contextlib import AbstractContextManager
|
||||
from typing import Any, Literal, overload
|
||||
from typing import Any, Literal, Protocol, overload, type_check_only
|
||||
from typing_extensions import Self, TypeAlias, deprecated
|
||||
|
||||
from psutil._common import (
|
||||
@@ -234,11 +234,18 @@ class Popen(Process):
|
||||
def __getattribute__(self, name: str) -> Any: ...
|
||||
def __dir__(self) -> list[str]: ...
|
||||
|
||||
@type_check_only
|
||||
class _ProcessIterCallable(Protocol):
|
||||
def __call__(
|
||||
self, attrs: list[str] | tuple[str, ...] | set[str] | frozenset[str] | None = None, ad_value=None
|
||||
) -> Iterator[Process]: ...
|
||||
def cache_clear(self) -> None: ...
|
||||
|
||||
def pids() -> list[int]: ...
|
||||
def pid_exists(pid: int) -> bool: ...
|
||||
def process_iter(
|
||||
attrs: list[str] | tuple[str, ...] | set[str] | frozenset[str] | None = None, ad_value=None
|
||||
) -> Iterator[Process]: ...
|
||||
|
||||
process_iter: _ProcessIterCallable
|
||||
|
||||
def wait_procs(
|
||||
procs: Iterable[Process], timeout: float | None = None, callback: Callable[[Process], object] | None = None
|
||||
) -> tuple[list[Process], list[Process]]: ...
|
||||
|
||||
Reference in New Issue
Block a user