From 0d88ed11ff7f23ca1dfeb79e3bb68c64ae0cf9ec Mon Sep 17 00:00:00 2001 From: Tareq Al-Ahdal Date: Sun, 7 Aug 2022 06:17:51 +0800 Subject: [PATCH 1/2] Added type hinting for psutil virtual memory stubs --- stubs/psutil/psutil/__init__.pyi | 2 +- stubs/psutil/psutil/_psbsd.pyi | 2 +- stubs/psutil/psutil/_pslinux.pyi | 2 +- stubs/psutil/psutil/_psosx.pyi | 2 +- stubs/psutil/psutil/_pswindows.pyi | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/stubs/psutil/psutil/__init__.pyi b/stubs/psutil/psutil/__init__.pyi index a7ea030c1e01..012dbb854791 100644 --- a/stubs/psutil/psutil/__init__.pyi +++ b/stubs/psutil/psutil/__init__.pyi @@ -220,7 +220,7 @@ def cpu_times_percent(interval: float | None = ..., percpu: bool = ...): ... def cpu_stats() -> scpustats: ... def cpu_freq(percpu: bool = ...) -> scpufreq: ... def getloadavg() -> tuple[float, float, float]: ... -def virtual_memory(): ... +def virtual_memory() -> Any: ... def swap_memory() -> sswap: ... def disk_usage(path: str) -> sdiskusage: ... def disk_partitions(all: bool = ...) -> list[sdiskpart]: ... diff --git a/stubs/psutil/psutil/_psbsd.pyi b/stubs/psutil/psutil/_psbsd.pyi index 5a166f2bf386..6489748990cd 100644 --- a/stubs/psutil/psutil/_psbsd.pyi +++ b/stubs/psutil/psutil/_psbsd.pyi @@ -85,7 +85,7 @@ class sdiskio(NamedTuple): write_time: Any busy_time: Any -def virtual_memory(): ... +def virtual_memory() -> Any: ... def swap_memory(): ... def cpu_times(): ... def per_cpu_times(): ... diff --git a/stubs/psutil/psutil/_pslinux.pyi b/stubs/psutil/psutil/_pslinux.pyi index f7c70a7455b9..70b67f32665d 100644 --- a/stubs/psutil/psutil/_pslinux.pyi +++ b/stubs/psutil/psutil/_pslinux.pyi @@ -121,7 +121,7 @@ scputimes: Any prlimit: Any def calculate_avail_vmem(mems): ... -def virtual_memory(): ... +def virtual_memory() -> Any: ... def swap_memory(): ... def cpu_times(): ... def per_cpu_times(): ... diff --git a/stubs/psutil/psutil/_psosx.pyi b/stubs/psutil/psutil/_psosx.pyi index ead3f1d7ec45..9ad89c1b61c2 100644 --- a/stubs/psutil/psutil/_psosx.pyi +++ b/stubs/psutil/psutil/_psosx.pyi @@ -43,7 +43,7 @@ class pmem(NamedTuple): pfullmem: Any -def virtual_memory(): ... +def virtual_memory() -> Any: ... def swap_memory(): ... def cpu_times(): ... def per_cpu_times(): ... diff --git a/stubs/psutil/psutil/_pswindows.pyi b/stubs/psutil/psutil/_pswindows.pyi index 93fd4380a9a6..57e0f3748f3c 100644 --- a/stubs/psutil/psutil/_pswindows.pyi +++ b/stubs/psutil/psutil/_pswindows.pyi @@ -101,7 +101,7 @@ class pio(NamedTuple): def convert_dos_path(s): ... def py2_strencode(s): ... def getpagesize(): ... -def virtual_memory(): ... +def virtual_memory() -> Any: ... def swap_memory(): ... disk_io_counters: Any From 0a56ee4ed436ec166788891c8336dff28ea76265 Mon Sep 17 00:00:00 2001 From: Tareq Al-Ahdal Date: Sun, 7 Aug 2022 20:12:44 +0800 Subject: [PATCH 2/2] Used 'svmem' as a return type for virtual_memory() --- stubs/psutil/psutil/__init__.pyi | 9 +++++---- stubs/psutil/psutil/_psbsd.pyi | 2 +- stubs/psutil/psutil/_pslinux.pyi | 2 +- stubs/psutil/psutil/_psosx.pyi | 2 +- stubs/psutil/psutil/_pswindows.pyi | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/stubs/psutil/psutil/__init__.pyi b/stubs/psutil/psutil/__init__.pyi index 012dbb854791..2330710a228f 100644 --- a/stubs/psutil/psutil/__init__.pyi +++ b/stubs/psutil/psutil/__init__.pyi @@ -102,14 +102,15 @@ if sys.platform == "win32": ) if sys.platform == "linux": - from ._pslinux import pfullmem, pmem + from ._pslinux import pfullmem, pmem, svmem elif sys.platform == "darwin": - from ._psosx import pfullmem, pmem + from ._psosx import pfullmem, pmem, svmem elif sys.platform == "win32": - from ._pswindows import pfullmem, pmem + from ._pswindows import pfullmem, pmem, svmem else: class pmem(Any): ... class pfullmem(Any): ... + class svmem(Any): ... if sys.platform == "linux": PROCFS_PATH: str @@ -220,7 +221,7 @@ def cpu_times_percent(interval: float | None = ..., percpu: bool = ...): ... def cpu_stats() -> scpustats: ... def cpu_freq(percpu: bool = ...) -> scpufreq: ... def getloadavg() -> tuple[float, float, float]: ... -def virtual_memory() -> Any: ... +def virtual_memory() -> svmem: ... def swap_memory() -> sswap: ... def disk_usage(path: str) -> sdiskusage: ... def disk_partitions(all: bool = ...) -> list[sdiskpart]: ... diff --git a/stubs/psutil/psutil/_psbsd.pyi b/stubs/psutil/psutil/_psbsd.pyi index 6489748990cd..a9f87ff0c5b4 100644 --- a/stubs/psutil/psutil/_psbsd.pyi +++ b/stubs/psutil/psutil/_psbsd.pyi @@ -85,7 +85,7 @@ class sdiskio(NamedTuple): write_time: Any busy_time: Any -def virtual_memory() -> Any: ... +def virtual_memory() -> svmem: ... def swap_memory(): ... def cpu_times(): ... def per_cpu_times(): ... diff --git a/stubs/psutil/psutil/_pslinux.pyi b/stubs/psutil/psutil/_pslinux.pyi index 70b67f32665d..e68bf02056cc 100644 --- a/stubs/psutil/psutil/_pslinux.pyi +++ b/stubs/psutil/psutil/_pslinux.pyi @@ -121,7 +121,7 @@ scputimes: Any prlimit: Any def calculate_avail_vmem(mems): ... -def virtual_memory() -> Any: ... +def virtual_memory() -> svmem: ... def swap_memory(): ... def cpu_times(): ... def per_cpu_times(): ... diff --git a/stubs/psutil/psutil/_psosx.pyi b/stubs/psutil/psutil/_psosx.pyi index 9ad89c1b61c2..9affcc5cf16e 100644 --- a/stubs/psutil/psutil/_psosx.pyi +++ b/stubs/psutil/psutil/_psosx.pyi @@ -43,7 +43,7 @@ class pmem(NamedTuple): pfullmem: Any -def virtual_memory() -> Any: ... +def virtual_memory() -> svmem: ... def swap_memory(): ... def cpu_times(): ... def per_cpu_times(): ... diff --git a/stubs/psutil/psutil/_pswindows.pyi b/stubs/psutil/psutil/_pswindows.pyi index 57e0f3748f3c..15625c7ffe98 100644 --- a/stubs/psutil/psutil/_pswindows.pyi +++ b/stubs/psutil/psutil/_pswindows.pyi @@ -101,7 +101,7 @@ class pio(NamedTuple): def convert_dos_path(s): ... def py2_strencode(s): ... def getpagesize(): ... -def virtual_memory() -> Any: ... +def virtual_memory() -> svmem: ... def swap_memory(): ... disk_io_counters: Any