From 4a161cd20703e30f5278733189f87fbeb76e816e Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 8 Aug 2024 12:02:26 -0400 Subject: [PATCH] Address PR comments --- newsfragments/4505.feature.rst | 2 +- setuptools/command/easy_install.py | 5 ++++- setuptools/extension.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/newsfragments/4505.feature.rst b/newsfragments/4505.feature.rst index 9d1676a074d..e032dd997ef 100644 --- a/newsfragments/4505.feature.rst +++ b/newsfragments/4505.feature.rst @@ -1 +1 @@ -Changed the order of type checks in ``setuptools.command.easy_install.CommandSpec.from_param`` to support any `collections.abc.Iterable` of `str` param and to always fallback to the environment if the param type is unsupported -- by :user:`Avasam` +Changed the order of type checks in ``setuptools.command.easy_install.CommandSpec.from_param`` to support any `collections.abc.Iterable` of `str` param -- by :user:`Avasam` diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index aee4fa6d77a..74b79d1adc8 100644 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -2070,7 +2070,10 @@ def from_param(cls, param: Self | str | Iterable[str] | None) -> Self: return cls.from_string(param) if isinstance(param, Iterable): return cls(param) - return cls.from_environment() + if param is None: + return cls.from_environment() + # AttributeError to keep backwards compatibility, this should really be a TypeError though + raise AttributeError(f"Argument has an unsupported type {type(param)}") @classmethod def from_environment(cls): diff --git a/setuptools/extension.py b/setuptools/extension.py index e4f2d945e1b..c385dcb0ac8 100644 --- a/setuptools/extension.py +++ b/setuptools/extension.py @@ -128,7 +128,7 @@ class Extension(_Extension): """ def __init__( - self, name: str, sources: list[str], *args, py_limited_api: bool = False, **kw + self, name: str, sources, *args, py_limited_api: bool = False, **kw ): # The *args is needed for compatibility as calls may use positional # arguments. py_limited_api may be set only via keyword.