|
10 | 10 | from .monkey import get_unpatched |
11 | 11 |
|
12 | 12 | import distutils.core |
13 | | -import distutils.errors |
14 | | -import distutils.extension |
15 | 13 |
|
16 | 14 |
|
17 | 15 | def _have_cython() -> bool: |
@@ -142,23 +140,38 @@ class Extension(_Extension): |
142 | 140 | _needs_stub: bool #: Private API, internal use only. |
143 | 141 | _file_name: str #: Private API, internal use only. |
144 | 142 |
|
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) |
162 | 175 |
|
163 | 176 | def _convert_pyx_sources_to_lang(self): |
164 | 177 | """ |
|
0 commit comments