8000 Improve stubgen tests by bluenote10 · Pull Request #16760 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Improve stubgen tests #16760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rename pybind11 test project from 'pybind11_mypy_demo' to 'pybind11_f…
…ixtures'
  • Loading branch information
bluenote10 committed Jan 13, 2024
commit 90c767444a414052ade739ca585f9c4ec241f721
2 changes: 1 addition & 1 deletion .github/workflows/test_stubgenc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test stubgenc on pybind11-mypy-demo
name: Test stubgenc on pybind11_fixtures

on:
workflow_dispatch:
Expand Down
8 changes: 4 additions & 4 deletions misc/test-stubgenc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cd "$(dirname "$0")/.."

# Install dependencies, demo project and mypy
python -m pip install -r test-requirements.txt
python -m pip install ./test-data/pybind11_mypy_demo
python -m pip install ./test-data/pybind11_fixtures
python -m pip install .

EXIT=0
Expand All @@ -17,7 +17,7 @@ EXIT=0
# everything else is passed to stubgen as its arguments
function stubgenc_test() {
# Remove expected stubs and generate new inplace
STUBGEN_OUTPUT_FOLDER=./test-data/pybind11_mypy_demo/$1
STUBGEN_OUTPUT_FOLDER=./test-data/pybind11_fixtures/$1
rm -rf "${STUBGEN_OUTPUT_FOLDER:?}"

stubgen -o "$STUBGEN_OUTPUT_FOLDER" "${@:2}"
Expand All @@ -38,8 +38,8 @@ function stubgenc_test() {
}

# create stubs without docstrings
stubgenc_test expected_stubs_no_docs -p pybind11_mypy_demo
stubgenc_test expected_stubs_no_docs -p pybind11_fixtures
# create stubs with docstrings
stubgenc_test expected_stubs_with_docs -p pybind11_mypy_demo --include-docstrings
stubgenc_test expected_stubs_with_docs -p pybind11_fixtures --include-docstrings

exit $EXIT
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ class Point:
degree: ClassVar[Point.AngleUnit] = ...
radian: ClassVar[Point.AngleUnit] = ...
def __init__(self, value: int) -> None:
"""__init__(self: pybind11_mypy_demo.demo.Point.AngleUnit, value: int) -> None"""
"""__init__(self: pybind11_fixtures.demo.Point.AngleUnit, value: int) -> None"""
def __eq__(self, other: object) -> bool:
"""__eq__(self: object, other: object) -> bool"""
def __hash__(self) -> int:
"""__hash__(self: object) -> int"""
def __index__(self) -> int:
"""__index__(self: pybind11_mypy_demo.demo.Point.AngleUnit) -> int"""
"""__index__(self: pybind11_fixtures.demo.Point.AngleUnit) -> int"""
def __int__(self) -> int:
"""__int__(self: pybind11_mypy_demo.demo.Point.AngleUnit) -> int"""
"""__int__(self: pybind11_fixtures.demo.Point.AngleUnit) -> int"""
def __ne__(self, other: object) -> bool:
"""__ne__(self: object, other: object) -> bool"""
@property
Expand All @@ -33,15 +33,15 @@ class Point:
mm: ClassVar[Point.LengthUnit] = ...
pixel: ClassVar[Point.LengthUnit] = ...
def __init__(self, value: int) -> None:
"""__init__(self: pybind11_mypy_demo.demo.Point.LengthUnit, value: int) -> None"""
"""__init__(self: pybind11_fixtures.demo.Point.LengthUnit, value: int) -> None"""
def __eq__(self, other: object) -> bool:
"""__eq__(self: object, other: object) -> bool"""
def __hash__(self) -> int:
"""__hash__(self: object) -> int"""
def __index__(self) -> int:
"""__index__(self: pybind11_mypy_demo.demo.Point.LengthUnit) -> int"""
"""__index__(self: pybind11_fixtures.demo.Point.LengthUnit) -> int"""
def __int__(self) -> int:
"""__int__(self: pybind11_mypy_demo.demo.Point.LengthUnit) -> int"""
"""__int__(self: pybind11_fixtures.demo.Point.LengthUnit) -> int"""
def __ne__(self, other: object) -> bool:
"""__ne__(self: object, other: object) -> bool"""
@property
Expand All @@ -60,38 +60,38 @@ class Point:
"""__init__(*args, **kwargs)
Overloaded function.

1. __init__(self: pybind11_mypy_demo.demo.Point) -> None
1. __init__(self: pybind11_fixtures.demo.Point) -> None

2. __init__(self: pybind11_mypy_demo.demo.Point, x: float, y: float) -> None
2. __init__(self: pybind11_fixtures.demo.Point, x: float, y: float) -> None
"""
@overload
def __init__(self, x: float, y: float) -> None:
"""__init__(*args, **kwargs)
Overloaded function.

1. __init__(self: pybind11_mypy_demo.demo.Point) -> None
1. __init__(self: pybind11_fixtures.demo.Point) -> None

2. __init__(self: pybind11_mypy_demo.demo.Point, x: float, y: float) -> None
2. __init__(self: pybind11_fixtures.demo.Point, x: float, y: float) -> None
"""
def as_list(self) -> List[float]:
"""as_list(self: pybind11_mypy_demo.demo.Point) -> List[float]"""
"""as_list(self: pybind11_fixtures.demo.Point) -> List[float]"""
@overload
def distance_to(self, x: float, y: float) -> float:
"""distance_to(*args, **kwargs)
Overloaded function.

1. distance_to(self: pybind11_mypy_demo.demo.Point, x: float, y: float) -> float
1. distance_to(self: pybind11_fixtures.demo.Point, x: float, y: float) -> float

2. distance_to(self: pybind11_mypy_demo.demo.Point, other: pybind11_mypy_demo.demo.Point) -> float
2. distance_to(self: pybind11_fixtures.demo.Point, other: pybind11_fixtures.demo.Point) -> float
"""
@overload
def distance_to(self, other: Point) -> float:
"""distance_to(*args, **kwargs)
Overloaded function.

1. distance_to(self: pybind11_mypy_demo.demo.Point, x: float, y: float) -> float
1. distance_to(self: pybind11_fixtures.demo.Point, x: float, y: float) -> float

2. distance_to(self: pybind11_mypy_demo.demo.Point, other: pybind11_mypy_demo.demo.Point) -> float
2. distance_to(self: pybind11_fixtures.demo.Point, other: pybind11_fixtures.demo.Point) -> float
"""
@property
def length(self) -> float: ...
Expand Down
< A3DB tr data-hunk="84f59689e7c205e54f9c9fc973c01c2c2e31d70d3f89eca5881d889a57cc0f7d" class="show-top-border">
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
# Documentation: https://pybind11.readthedocs.io/en/stable/compiling.html
ext_modules = [
Pybind11Extension(
"pybind11_mypy_demo",
"pybind11_fixtures",
["src/main.cpp"],
cxx_std=17,
),
]

setup(
name="pybind11-mypy-demo",
name="pybind11_fixtures",
version="0.0.1",
ext_modules=ext_modules,
)
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ void bind_demo(py::module& m) {
// Module entry point
// ----------------------------------------------------------------------------

PYBIND11_MODULE(pybind11_mypy_demo, m) {
PYBIND11_MODULE(pybind11_fixtures, m) {
bind_test_cases(m);

auto demo = m.def_submodule("demo");
Expand Down
0