Skip to content

Commit 5c9dcc8

Browse files
committed
type setuptools.extension.Extension from Typeshed
1 parent d198e86 commit 5c9dcc8

File tree

1 file changed

+32
-19
lines changed

1 file changed

+32
-19
lines changed

setuptools/extension.py

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
from .monkey import get_unpatched
1111

1212
import distutils.core
13-
import distutils.errors
14-
import distutils.extension
1513

1614

1715
def _have_cython() -> bool:
@@ -142,23 +140,38 @@ class Extension(_Extension):
142140
_needs_stub: bool #: Private API, internal use only.
143141
_file_name: str #: Private API, internal use only.
144142

145-
def __init__(
146-
self,
147-
name: str,
148-
sources: Iterable[StrPath],
149-
*args,
150-
py_limited_api: bool = False,
151-
**kw,
152-
) -> None:
153-
# The *args is needed for compatibility as calls may use positional
154-
# arguments. py_limited_api may be set only via keyword.
155-
self.py_limited_api = py_limited_api
156-
super().__init__(
157-
name,
158-
sources, # type: ignore[arg-type] # Vendored version of setuptools supports PathLike
159-
*args,
160-
**kw,
161-
)
143+
if TYPE_CHECKING:
144+
# Same as distutils.extension.Extension, with an extra py_limited_api kwarg,
145+
# and without **kw meant to catch unknown keywords
146+
def __init__(
147+
self,
148+
name: str,
149+
sources: Iterable[StrPath],
150+
include_dirs: list[str] | None = None,
151+
define_macros: list[tuple[str, str | None]] | None = None,
152+
undef_macros: list[str] | None = None,
153+
library_dirs: list[str] | None = None,
154+
libraries: list[str] | None = None,
155+
runtime_library_dirs: list[str] | None = None,
156+
extra_objects: list[str] | None = None,
157+
extra_compile_args: list[str] | None = None,
158+
extra_link_args: list[str] | None = None,
159+
export_symbols: list[str] | None = None,
160+
swig_opts: list[str] | None = None,
161+
depends: list[str] | None = None,
162+
language: str | None = None,
163+
optional: bool | None = None,
164+
*,
165+
py_limited_api: bool = False,
166+
) -> None: ...
167+
168+
else:
169+
170+
def __init__(self, *args, py_limited_api: bool = False, **kw) -> None:
171+
# The *args is needed for compatibility as calls may use positional
172+
# arguments. py_limited_api may be set only via keyword.
173+
self.py_limited_api = py_limited_api
174+
super().__init__(*args, **kw)
162175

163176
def _convert_pyx_sources_to_lang(self):
164177
"""

0 commit comments

Comments
 (0)