|
5 | 5 | import inspect |
6 | 6 | import re |
7 | 7 | import types |
| 8 | +import typing |
8 | 9 | from typing import Any |
9 | 10 |
|
10 | 11 | from pybind11_stubgen.parser.errors import ( |
@@ -252,16 +253,16 @@ def handle_function(self, path: QualifiedName, func: Any) -> list[Function]: |
252 | 253 | func_args[arg_name].annotation = self.parse_annotation_str( |
253 | 254 | annotation |
254 | 255 | ) |
255 | | - elif not isinstance(annotation, type): |
256 | | - func_args[arg_name].annotation = self.handle_value(annotation) |
257 | 256 | elif self._is_generic_alias(annotation): |
258 | 257 | func_args[arg_name].annotation = self.parse_annotation_str( |
259 | 258 | str(annotation) |
260 | 259 | ) |
261 | | - else: |
| 260 | + elif isinstance(annotation, type): |
262 | 261 | func_args[arg_name].annotation = ResolvedType( |
263 | 262 | name=self.handle_type(annotation), |
264 | 263 | ) |
| 264 | + else: |
| 265 | + func_args[arg_name].annotation = self.handle_value(annotation) |
265 | 266 | if "return" in func_args: |
266 | 267 | returns = func_args["return"].annotation |
267 | 268 | else: |
@@ -293,7 +294,10 @@ def _is_generic_alias(self, annotation: type) -> bool: |
293 | 294 | generic_alias_t: type | None = getattr(types, "GenericAlias", None) |
294 | 295 | if generic_alias_t is None: |
295 | 296 | return False |
296 | | - return isinstance(annotation, generic_alias_t) |
| 297 | + typing_generic_alias_t = type(typing.List[int]) |
| 298 | + return isinstance(annotation, generic_alias_t) or isinstance( |
| 299 | + annotation, typing_generic_alias_t |
| 300 | + ) |
297 | 301 |
|
298 | 302 | def handle_import(self, path: QualifiedName, origin: Any) -> Import | None: |
299 | 303 | full_name = self._get_full_name(path, origin) |
|
0 commit comments