diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0eaf29..3544b82 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -159,4 +159,4 @@ jobs: - uses: pypa/gh-action-pypi-publish@v1.4.2 with: user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/pybind11_stubgen/parser/mixins/fix.py b/pybind11_stubgen/parser/mixins/fix.py index ef7f3a4..acbd3d0 100644 --- a/pybind11_stubgen/parser/mixins/fix.py +++ b/pybind11_stubgen/parser/mixins/fix.py @@ -9,7 +9,11 @@ from logging import getLogger from typing import Any -from pybind11_stubgen.parser.errors import NameResolutionError, ParserError +from pybind11_stubgen.parser.errors import ( + InvalidExpressionError, + NameResolutionError, + ParserError, +) from pybind11_stubgen.parser.interface import IParser from pybind11_stubgen.structs import ( Alias, @@ -804,9 +808,17 @@ def parse_value_str(self, value: str) -> Value | InvalidExpression: enum_class = self.parse_annotation_str(f"{prefix}.{enum_class_str}") if isinstance(enum_class, ResolvedType): return Value(repr=f"{enum_class.name}.{entry}", is_print_safe=True) - self._unknown_enum_classes.add(enum_class_str) return super().parse_value_str(value) + def report_error(self, error: ParserError) -> None: + if isinstance(error, InvalidExpressionError): + match = self._pybind11_enum_pattern.match(error.expression) + if match is not None: + enum_qual_name = match.group("enum") + enum_class_str, entry = enum_qual_name.rsplit(".", maxsplit=1) + self._unknown_enum_classes.add(enum_class_str) + super().report_error(error) + def finalize(self): if self._unknown_enum_classes: logger.warning(