diff --git a/mypy/dmypy_server.py b/mypy/dmypy_server.py index 166b174a141a..cf4b15e3e6aa 100644 --- a/mypy/dmypy_server.py +++ b/mypy/dmypy_server.py @@ -349,10 +349,10 @@ def cmd_hang(self) -> Dict[str, object]: MiB = 2**20 -def get_meminfo() -> Mapping[str, float]: +def get_meminfo() -> Dict[str, Any]: # See https://stackoverflow.com/questions/938733/total-memory-used-by-python-process import resource # Since it doesn't exist on Windows. - res = {} + res = {} # type: Dict[str, Any] rusage = resource.getrusage(resource.RUSAGE_SELF) if sys.platform == 'darwin': factor = 1 @@ -363,7 +363,11 @@ def get_meminfo() -> Mapping[str, float]: try: import psutil # type: ignore # It's not in typeshed yet except ImportError: - pass + if sys.platform != 'win32': + res['memory_psutil_missing'] = ( + 'psutil not found, run pip install mypy[dmypy] ' + 'to install the needed components for dmypy' + ) else: process = psutil.Process(os.getpid()) meminfo = process.memory_info() diff --git a/setup.py b/setup.py index 1bd24ab9a12c..8b7017281bf2 100644 --- a/setup.py +++ b/setup.py @@ -109,9 +109,9 @@ def run(self): classifiers=classifiers, cmdclass={'build_py': CustomPythonBuild}, install_requires = ['typed-ast >= 1.1.0, < 1.2.0', - 'psutil >= 5.4.0, < 5.5.0', ], extras_require = { ':python_version < "3.5"': 'typing >= 3.5.3', + 'dmypy': 'psutil >= 5.4.0, < 5.5.0; sys_platform!="win32"', }, )