Skip to content

Commit

Permalink
fix: Don't render pybind11 KeysView, ValuesView, ItemsView class defs
Browse files Browse the repository at this point in the history
  • Loading branch information
sizmailov committed Mar 4, 2024
1 parent f783045 commit a251317
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pybind11_stubgen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from pybind11_stubgen.parser.mixins.filter import (
FilterClassMembers,
FilterInvalidIdentifiers,
FilterPybind11ViewClasses,
FilterPybindInternals,
FilterTypingModuleAttributes,
)
Expand Down Expand Up @@ -273,6 +274,7 @@ class Parser(
FixValueReprRandomAddress,
FixRedundantBuiltinsAnnotation,
FilterPybindInternals,
FilterPybind11ViewClasses,
FixRedundantMethodsFromBuiltinObject,
RemoveSelfAnnotation,
FixPybind11EnumStrDoc,
Expand Down
19 changes: 19 additions & 0 deletions pybind11_stubgen/parser/mixins/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,22 @@ def handle_class_member(
self.report_error(InvalidIdentifierError(path[-1], path.parent))
return None
return super().handle_class_member(path, class_, obj)


class FilterPybind11ViewClasses(IParser):
def handle_module_member(
self, path: QualifiedName, module: types.ModuleType, obj: Any
) -> (
Docstring | Import | Alias | Class | list[Function] | Attribute | Module | None
):
result = super().handle_module_member(path, module, obj)

if isinstance(result, Class) and str(result.name) in [
"ItemsView",
"KeysView",
"ValuesView",
]:
# TODO: check obj is a subclass of pybind11_object
return None

return result

0 comments on commit a251317

Please sign in to comment.