Skip to content

Commit

Permalink
Add pybind-v2.12 stubs (identical to pybind-v2.13)
Browse files Browse the repository at this point in the history
  • Loading branch information
sizmailov committed Feb 24, 2025
1 parent 6bb7ab1 commit 94bda4d
Show file tree
Hide file tree
Showing 30 changed files with 527 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from __future__ import annotations

from demo._bindings import (
aliases,
classes,
eigen,
enum,
flawed_bindings,
functions,
issues,
methods,
numpy,
properties,
stl,
stl_bind,
typing,
values,
)

from . import _bindings, core, pure_python

__all__ = [
"aliases",
"classes",
"core",
"eigen",
"enum",
"flawed_bindings",
"functions",
"issues",
"methods",
"numpy",
"properties",
"pure_python",
"stl",
"stl_bind",
"typing",
"values",
"version",
]
version: str = "0.0.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from __future__ import annotations

import typing

import numpy
from numpy import random

import demo._bindings.enum
from demo._bindings.aliases.foreign_method_arg import Bar2 as foreign_type_alias
from demo._bindings.aliases.foreign_return import get_foo as foreign_class_alias

from . import (
foreign_arg,
foreign_attr,
foreign_class_member,
foreign_method_arg,
foreign_method_return,
foreign_return,
missing_self_arg,
)

__all__ = [
"Color",
"Dummy",
"foreign_arg",
"foreign_attr",
"foreign_class_alias",
"foreign_class_member",
"foreign_enum_default",
"foreign_method_arg",
"foreign_method_return",
"foreign_return",
"foreign_type_alias",
"func",
"local_func_alias",
"local_type_alias",
"missing_self_arg",
"random",
]

class Color:
pass

class Dummy:
linalg = numpy.linalg

def foreign_enum_default(
color: typing.Any = demo._bindings.enum.ConsoleForegroundColor.Blue,
) -> None: ...
def func(arg0: int) -> int: ...

local_func_alias = func
local_type_alias = Color
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from __future__ import annotations

import typing

__all__ = ["Base", "CppException", "Derived", "Foo", "Outer"]

class Base:
class Inner:
pass
name: str

class CppException(Exception):
pass

class Derived(Base):
count: int

class Foo:
class FooChild:
def __init__(self) -> None: ...
def g(self) -> None: ...

def __init__(self) -> None: ...
def f(self) -> None: ...

class Outer:
class Inner:
class NestedEnum:
"""
Members:
ONE
TWO
"""

ONE: typing.ClassVar[Outer.Inner.NestedEnum] # value = <NestedEnum.ONE: 1>
TWO: typing.ClassVar[Outer.Inner.NestedEnum] # value = <NestedEnum.TWO: 2>
__members__: typing.ClassVar[
dict[str, Outer.Inner.NestedEnum]
] # value = {'ONE': <NestedEnum.ONE: 1>, 'TWO': <NestedEnum.TWO: 2>}
def __eq__(self, other: typing.Any) -> bool: ...
def __getstate__(self) -> int: ...
def __hash__(self) -> int: ...
def __index__(self) -> int: ...
def __init__(self, value: int) -> None: ...
def __int__(self) -> int: ...
def __ne__(self, other: typing.Any) -> bool: ...
def __repr__(self) -> str: ...
def __setstate__(self, state: int) -> None: ...
def __str__(self) -> str: ...
@property
def name(self) -> str: ...
@property
def value(self) -> int: ...
value: Outer.Inner.NestedEnum
inner: Outer.Inner
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from __future__ import annotations

import typing

__all__ = [
"Foo",
"accept_annotated_callable",
"accept_callable",
"accept_frozenset",
"accept_py_handle",
"accept_py_object",
"accept_set",
"add",
"default_custom_arg",
"default_int_arg",
"default_list_arg",
"default_optional_arg",
"func_w_anon_args",
"func_w_named_pos_args",
"generic",
"mul",
"pass_callback",
"pos_kw_only_mix",
"pos_kw_only_variadic_mix",
]

class Foo:
def __init__(self, arg0: int) -> None: ...

def accept_annotated_callable(arg0: typing.Callable[[int, int], int]) -> typing.Any: ...
def accept_callable(arg0: typing.Callable) -> typing.Any: ...
def accept_frozenset(arg0: frozenset) -> None: ...
def accept_py_handle(arg0: typing.Any) -> str: ...
def accept_py_object(arg0: typing.Any) -> str: ...
def accept_set(arg0: set) -> None: ...
def add(arg0: int, arg1: int) -> int: ...
def default_custom_arg(foo: Foo = Foo(5)) -> None: ...
def default_int_arg(n: int = 5) -> None: ...
def default_list_arg(l: list = [1, 2, 6, 18]) -> None: ...
def default_optional_arg(n: int | None = None) -> None: ...
def func_w_anon_args(arg0: int, arg1: int, arg2: int) -> None: ...
def func_w_named_pos_args(x: int, y: int, z: int) -> None: ...
def generic(*args, **kwargs) -> None: ...
@typing.overload
def mul(x: int, y: int) -> int:
"""
Multiply x and y (int)
"""

@typing.overload
def mul(p: float, q: float) -> float:
"""
Multiply p and q (double)
"""

def pass_callback(arg0: typing.Callable[[Foo], Foo]) -> Foo: ...
def pos_kw_only_mix(i: int, /, j: int, *, k: int) -> tuple: ...
def pos_kw_only_variadic_mix(i: int, /, j: int, *args, k: int, **kwargs) -> tuple: ...
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
from __future__ import annotations

import typing

__all__ = [
"WithGetterSetterDoc",
"WithPropAndGetterSetterDoc",
"WithPropDoc",
"WithoutDoc",
]

class WithGetterSetterDoc:
"""
User docstring provided via pybind11::cpp_function(..., doc) to getters/setters, but NOT to `def_*(..., doc)` calls
"""

def_property_readonly_static: typing.ClassVar[int] = 0
def_property_static: typing.ClassVar[int] = 0
@property
def def_property(self) -> int:
"""
getter doc token
"""
@def_property.setter
def def_property(self, arg1: int) -> None:
"""
setter doc token
"""
@property
def def_property_readonly(self) -> int:
"""
getter doc token
"""

class WithPropAndGetterSetterDoc:
"""
User docstring provided via pybind11::cpp_function(..., doc) to getters/setters and to `def_*(, doc)` calls
"""

def_property_readonly_static: typing.ClassVar[int] = 0
def_property_static: typing.ClassVar[int] = 0
@property
def def_property(self) -> int:
"""
prop doc token
"""
@def_property.setter
def def_property(self, arg1: int) -> None: ...
@property
def def_property_readonly(self) -> int:
"""
prop doc token
"""

class WithPropDoc:
"""
User docstring provided only to `def_` calls
"""

def_property_readonly_static: typing.ClassVar[int] = 0
def_property_static: typing.ClassVar[int] = 0
@property
def def_property(self) -> int:
"""
prop doc token
"""
@def_property.setter
def def_property(self, arg1: int) -> None: ...
@property
def def_property_readonly(self) -> int:
"""
prop doc token
"""
@property
def def_readonly(self) -> int:
"""
prop doc token
"""
@property
def def_readwrite(self) -> int:
"""
prop doc token
"""
@def_readwrite.setter
def def_readwrite(self, arg0: int) -> None: ...

class WithoutDoc:
"""
No user docstring provided
"""

def_property_readonly_static: typing.ClassVar[int] = 0
def_property_static: typing.ClassVar[int] = 0
def_property: int
def_readwrite: int
@property
def def_property_readonly(self) -> int: ...
@property
def def_readonly(self) -> int: ...
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from __future__ import annotations

import typing

import pybind11_stubgen.typing_ext

__all__ = ["std_array", "std_map", "std_optional", "std_variant", "std_vector"]

def std_array(
arg0: typing.Annotated[list[int], pybind11_stubgen.typing_ext.FixedSize(3)]
) -> typing.Annotated[list[int], pybind11_stubgen.typing_ext.FixedSize(3)]: ...
def std_map() -> dict[int, complex]: ...
def std_optional(arg0: int | None) -> None: ...
def std_variant(arg0: int | float | tuple[int, int]) -> None: ...
def std_vector() -> list[tuple[int, float]]: ...
Loading

0 comments on commit 94bda4d

Please sign in to comment.