8000 [stubgenc] Test stub generation on pybind11-mypy-demo project · python/mypy@d8f365a · GitHub
[go: up one dir, main page]

Skip to content

Commit d8f365a

Browse files
committed
[stubgenc] Test stub generation on pybind11-mypy-demo project
1 parent e00f795 commit d8f365a

File tree

4 files changed

+94
-0
lines changed

4 files changed

+94
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Test stubgenc on pybind11-mypy-demo
2+
3+
on:
4+
push:
5+
branches: [master]
6+
tags: ['*']
7+
pull_request:
8+
paths:
9+
- 'misc/test-stubgenc.sh'
10+
- 'mypy/stubgenc.py'
11+
- 'mypy/stubdoc.py'
12+
- 'test-data/stubgen/**'
13+
14+
jobs:
15+
stubgenc:
16+
# Check stub file generation for a small pybind11 project
17+
# (full text match is required to pass)
18+
runs-on: ubuntu-latest
19+
steps:
20+
21+
- uses: actions/checkout@v2
22+
23+
- name: initialize submodules
24+
run: git submodule update --init
25+
26+
- name: Setup 🐍 3.8
27+
uses: actions/setup-python@v2
28+
with:
29+
python-version: 3.8
30+
31+
- name: Test stubgenc
32+
run: misc/test-stubgenc.sh

misc/test-stubgenc.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
# This script is expected to be run from root of the mypy repo
3+
4+
# Install dependencies, demo project and mypy
5+
python -m pip install -r test-requirements.txt
6+
python -m pip install pybind11-mypy-demo==0.0.1
7+
python -m pip install .
8+
9+
# Remove expected stubs and generate new inplace
10+
rm -rf test-data/stubgen/pybind11_mypy_demo
11+
stubgen -p pybind11_mypy_demo -o test-data/stubgen/
12+
13+
# Compare generated stubs to expected ones
14+
git diff --exit-code test-data/stubgen/pybind11_mypy_demo

test-data/stubgen/pybind11_mypy_demo/__init__.pyi

Whitespace-only changes.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from typing import Any
2+
3+
from typing import overload
4+
PI: float
5+
6+
def answer() -> int: ...
7+
def midpoint(left: float, right: float) -> float: ...
8+
def sum(arg0: int, arg1: int) -> int: ...
9+
def weighted_midpoint(left: float, right: float, alpha: float = ...) -> float: ...
10+
11+
class Point:
12+
AngleUnit: Any = ...
13+
LengthUnit: Any = ...
14+
origin: Any = ...
15+
@overload
16+
def __init__(self) -> None: ...
17+
@overload
18+
def __init__(self, x: float, y: float) -> None: ...
19+
@overload
20+
def __init__(*args, **kwargs) -> Any: ...
21+
@overload
22+
def distance_to(self, x: float, y: float) -> float: ...
23+
@overload
24+
def distance_to(self, other: Point) -> float: ...
25+
@overload
26+
def distance_to(*args, **kwargs) -> Any: ...
27+
@property
28+
def angle_unit(self) -> pybind11_mypy_demo.basics.Point.AngleUnit: ...
29+
@angle_unit.setter
30+
def angle_unit(self, val: pybind11_mypy_demo.basics.Point.AngleUnit) -> None: ...
31+
@property
32+
def length(self) -> float: ...
33+
@property
34+
def length_unit(self) -> pybind11_mypy_demo.basics.Point.LengthUnit: ...
35+
@length_unit.setter
36+
def length_unit(self, val: pybind11_mypy_demo.basics.Point.LengthUnit) -> None: ...
37+
@property
38+
def x(self) -> float: ...
39+
@x.setter
40+
def x(self, val: float) -> None: ...
41+
@property
42+
def x_axis(self) -> pybind11_mypy_demo.basics.Point: ...
43+
@property
44+
def y(self) -> float: ...
45+
@y.setter
46+
def y(self, val: float) -> None: ...
47+
@property
48+
def y_axis(self) -> pybind11_mypy_demo.basics.Point: ...

0 commit comments

Comments
 (0)
0