Skip to content

Commit

Permalink
fix: Misleading warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
sizmailov committed Oct 23, 2023
1 parent c34105a commit c75cd22
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,4 @@ jobs:
- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
password: ${{ secrets.PYPI_API_TOKEN }}
16 changes: 14 additions & 2 deletions pybind11_stubgen/parser/mixins/fix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit c75cd22

Please sign in to comment.