8000 [stubgenc] Test stub generation for example pybind11 project · python/mypy@ebd8d01 · GitHub
[go: up one dir, main page]

Skip to content

Commit ebd8d01

Browse files
committed
[stubgenc] Test stub generation for example pybind11 project
1 parent 34b14b7 commit ebd8d01

File tree

8 files changed

+214
-0
lines changed

8 files changed

+214
-0
lines changed

.github/workflows/test.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,33 @@ jobs:
4747
run: tox -e ${{ matrix.toxenv }} --notest
4848
- name: test
4949
run: tox -e ${{ matrix.toxenv }} --skip-pkg-install
50+
51+
stubgenc:
52+
# Check stub file generation for a small pybind11 project
53+
# (full text match is required to pass)
54+
runs-on: ubuntu-latest
55+
steps:
56+
57+
- uses: actions/checkout@v2
58+
59+
- name: initialize submodules
60+
run: git submodule update --init
61+
62+
- name: Setup 🐍 3.8
63+
uses: actions/setup-python@v2
64+
with:
65+
python-version: 3.8
66+
67+
- name: Prepare env
68+
run: |
69+
python -m pip install -r test-requirements.txt
70+
python -m pip install .
71+
72+
- name: Run stubgen
73+
run: |
74+
rm -rf test-data/stubgen/python_example
75+
stubgen -p python_example -o test-data/stubgen/
76+
77+
- name: Check output
78+
run: |
79+
git diff --exit-code test-data/stubgen/
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from typing import Any
2+
3+
foolist: Any
4+
foovar: Any
5+
list_with_none: Any
6+
none: Any
7+
8+
class Base:
9+
Inner: Any = ...
10+
def __init__(self, *args, **kwargs) -> None: ...
11+
@property
12+
def name(self) -> str: ...
13+
@name.setter
14+
def name(self, val: str) -> None: ...
15+
16+
class CppException(Exception): ...
17+
18+
class Derived(Base):
19+
def __init__(self, *args, **kwargs) -> None: ...
20+
@property
21+
def count(self) -> int: ...
22+
@count.setter
23+
def count(self, val: int) -> None: ...
24+
25+
class Foo:
26+
FooChild: Any = ...
27+
def __init__(self) -> None: ...
28+
def f(self) -> None: ...
29+
30+
class Outer:
31+
Inner: Any = ...
32+
linalg: Any = ...
33+
def __init__(self, *args, **kwargs) -> None: ...
34+
@property
35+
def inner(self) -> python_example.Outer.Inner: ...
36+
@inner.setter
37+
def inner(self, val: python_example.Outer.Inner) -> None: ...
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from typing import Dict, List, Tuple
2+
3+
def get_complex_map() -> Dict[int,complex]: ...
4+
def get_vector_of_pairs() -> List[Tuple[int,float]]: ...
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from typing import Any
2+
3+
def accept_unbound_enum(arg0) -> int: ...
4+
def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ...
5+
def accept_unbound_type(arg0) -> int: ...
6+
def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ...
7+
def get_unbound_type(*args, **kwargs) -> Any: ...
8+
9+
class Enum:
10+
def __init__(self, *args, **kwargs) -> None: ...
11+
12+
class Unbound:
13+
def __init__(self, *args, **kwargs) -> None: ...
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import numpy
2+
3+
def accept_ndarray_float64(arg0: numpy.ndarray[numpy.float64]) -> None: ...
4+
def accept_ndarray_int(arg0: numpy.ndarray[numpy.int32]) -> None: ...
5+
def get_ndarray_float64() -> numpy.ndarray[numpy.float64]: ...
6+
def get_ndarray_int() -> numpy.ndarray[numpy.int32]: ...
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
from typing import Any, Iterable, Iterator, Tuple
2+
3+
from typing import overload
4+
5+
def get_complex_map() -> MapStringComplex: ...
6+
def get_vector_of_pairs() -> VectorPairStringDouble: ...
7+
8+
class MapStringComplex:
9+
def __init__(self) -> None: ...
10+
def items(self) -> Iterator: ...
11+
def __bool__(self) -> bool: ...
12+
def __contains__(self, arg0: str) -> bool: ...
13+
def __delitem__(self, arg0: str) -> None: ...
14+
def __getitem__(self, arg0: str) -> complex: ...
15+
def __iter__(self) -> Iterator: ...
16+
def __len__(self) -> int: ...
17+
def __setitem__(self, arg0: str, arg1: complex) -> None: ...
18+
19+
class VectorPairStringDouble:
20+
__hash__: Any = ...
21+
@overload
22+
def __init__(self) -> None: ...
23+
@overload
24+
def __init__(self, arg0: VectorPairStringDouble) -> None: ...
25+
@overload
26+
def __init__(self, arg0: Iterable) -> None: ...
27+
@overload
28+
def __init__(*args, **kwargs) -> Any: ...
29+
def append(self, x: Tuple[str,float]) -> None: ...
30+
def clear(self) -> None: ...
31+
def count(self, x: Tuple[str,float]) -> int: ...
32+
@overload
33+
def extend(self, L: VectorPairStringDouble) -> None: ...
34+
@overload
35+
def extend(self, L: Iterable) -> None: ...
36+
@overload
37+
def extend(*args, **kwargs) -> Any: ...
38+
def insert(self, i: int, x: Tuple[str,float]) -> None: ...
39+
@overload
40+
def pop(self) -> Tuple[str,float]: ...
41+
@overload
42+
def pop(self, i: int) -> Tuple[str,float]: ...
43+
@overload
44+
def pop(*args, **kwargs) -> Any: ...
45+
def remove(self, x: Tuple[str,float]) -> None: ...
46+
def __bool__(self) -> bool: ...
47+
def __contains__(self, x: Tuple[str,float]) -> bool: ...
48+
@overload
49+
def __delitem__(self, arg0: int) -> None: ...
50+
@overload
51+
def __delitem__(self, arg0: slice) -> None: ...
52+
@overload
53+
def __delitem__(*args, **kwargs) -> Any: ...
54+
def __eq__(self, arg0: VectorPairStringDouble) -> bool: ...
55+
@overload
56+
def __getitem__(self, s: slice) -> VectorPairStringDouble: ...
57+
@overload
58+
def __getitem__(self, arg0: int) -> Tuple[str,float]: ...
59+
@overload
60+
def __getitem__(*args, **kwargs) -> Any: ...
61+
def __iter__(self) -> Iterator: ...
62+
def __len__(self) -> int: ...
63+
def __ne__(self, arg0: VectorPairStringDouble) -> bool: ...
64+
@overload
65+
def __setitem__(self, arg0: int, arg1: Tuple[str,float]) -> None: ...
66+
@overload
67+
def __setitem__(self, arg0: slice, arg1: VectorPairStringDouble) -> None: ...
68+
@overload
69+
def __setitem__(*args, **kwargs) -> Any: ...
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
from typing import Any
2+
3+
Blue: Any
4+
Green: Any
5+
Magenta: Any
6+
Yellow: Any
7+
8+
EED3 def accept_defaulted_enum(color: ConsoleForegroundColor = ...) -> None: ...
9+
def add(arg0: int, arg1: int) -> int: ...
10+
11+
class ConsoleBackgroundColor:
12+
Blue: Any = ...
13+
Green: Any = ...
14+
Magenta: Any = ...
15+
Yellow: Any = ...
16+
__entries: Any = ...
17+
def __init__(self, value: int) -> None: ...
18+
def __eq__(self, other: object) -> bool: ...
19+
def __getstate__(self) -> int: ...
20+
def __hash__(self) -> int: ...
21+
def __index__(self) -> int: ...
22+
def __int__(self) -> int: ...
23+
def __ne__(self, other: object) -> bool: ...
24+
def __setstate__(self, state: int) -> None: ...
25+
@property
26+
def name(self) -> Any: ...
27+
@property
28+
def __doc__(self) -> Any: ...
29+
@property
30+
def __members__(self) -> Any: ...
31+
32+
class ConsoleForegroundColor:
33+
Blue: Any = ...
34+
Green: Any = ...
35+
Magenta: Any = ...
36+
Yellow: Any = ...
37+
__entries: Any = ...
38+
def __init__(self, value: int) -> None: ...
39+
def __eq__(self, other: object) -> bool: ...
40+
def __getstate__(self) -> int: ...
41+
def __hash__(self) -> int: ...
42+
def __index__(self) -> int: ...
43+
def __int__(self) -> int: ...
44+
def __ne__(self, other: object) -> bool: ...
45+
def __setstate__(self, state: int) -> None: ...
46+
@property
47+
def name(self) -> Any: ...
48+
@property
49+
def __doc__(self) -> Any: ...
50+
@property
51+
def __members__(self) -> Any: ...

test-requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ py>=1.5.2
1515
virtualenv<20
1616
setuptools!=50
1717
importlib-metadata==0.20
18+
# stubgen compatibility with pybind
19+
pybind11
20+
numpy
21+
git+https://github.com/sizmailov/python_example.git@mypy-stubgen-test

0 commit comments

Comments
 (0)
0