From 25bd25a7ca930631b546d511aebdfb7c5e868b27 Mon Sep 17 00:00:00 2001 From: Avasam Date: Fri, 1 Nov 2024 11:15:54 -0400 Subject: [PATCH] fix mypy failure after multiple merges --- setuptools/command/install.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/setuptools/command/install.py b/setuptools/command/install.py index 1262da0bc32..7f8e0a2b93a 100644 --- a/setuptools/command/install.py +++ b/setuptools/command/install.py @@ -4,7 +4,7 @@ import inspect import platform from collections.abc import Callable -from typing import Any, ClassVar, cast +from typing import TYPE_CHECKING, Any, ClassVar, cast import setuptools @@ -15,6 +15,12 @@ import distutils.command.install as orig from distutils.errors import DistutilsArgError +if TYPE_CHECKING: + # This is only used for a type-cast, don't import at runtime or it'll cause deprecation warnings + from .easy_install import easy_install as easy_install_cls +else: + easy_install_cls = None + # Prior to numpy 1.9, NumPy relies on the '_install' name, so provide it for # now. See https://github.com/pypa/setuptools/issues/199/ _install = orig.install @@ -131,7 +137,9 @@ def _called_from_setup(run_frame): return False def do_egg_install(self) -> None: - easy_install = self.distribution.get_command_class('easy_install') + easy_install = cast( + type[easy_install_cls], self.distribution.get_command_class('easy_install') + ) cmd = easy_install( self.distribution,