Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/test_stubgenc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- 'mypy/stubgenc.py'
- 'mypy/stubdoc.py'
- 'mypy/stubutil.py'
- 'test-data/stubgen/**'
- 'test-data/pybind11_fixtures/**'

permissions:
contents: read
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import os
import pathlib
import typing
from . import demo as demo
from typing import overload

class StaticMethods:
def __init__(self, *args, **kwargs) -> None: ...
@overload
@staticmethod
def overloaded_static_method(value: int) -> int: ...
def overloaded_static_method(value: typing.SupportsInt) -> int: ...
@overload
@staticmethod
def overloaded_static_method(value: float) -> float: ...
def overloaded_static_method(value: typing.SupportsFloat) -> float: ...
@staticmethod
def some_static_method(a: int, b: int) -> int: ...
def some_static_method(a: typing.SupportsInt, b: typing.SupportsInt) -> int: ...

class TestStruct:
field_readwrite: int
Expand All @@ -23,5 +24,5 @@ class TestStruct:
def func_incomplete_signature(*args, **kwargs): ...
def func_returning_optional() -> int | None: ...
def func_returning_pair() -> tuple[int, float]: ...
def func_returning_path() -> os.PathLike: ...
def func_returning_path() -> pathlib.Path: ...
def func_returning_vector() -> list[float]: ...
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import typing
from typing import ClassVar, overload

PI: float
Expand All @@ -9,7 +10,7 @@ class Point:
__entries: ClassVar[dict] = ...
degree: ClassVar[Point.AngleUnit] = ...
radian: ClassVar[Point.AngleUnit] = ...
def __init__(self, value: int) -> None: ...
def __init__(self, value: typing.SupportsInt) -> None: ...
def __eq__(self, other: object) -> bool: ...
def __hash__(self) -> int: ...
def __index__(self) -> int: ...
Expand All @@ -26,7 +27,7 @@ class Point:
inch: ClassVar[Point.LengthUnit] = ...
mm: ClassVar[Point.LengthUnit] = ...
pixel: ClassVar[Point.LengthUnit] = ...
def __init__(self, value: int) -> None: ...
def __init__(self, value: typing.SupportsInt) -> None: ...
def __eq__(self, other: object) -> bool: ...
def __hash__(self) -> int: ...
def __index__(self) -> int: ...
Expand All @@ -46,16 +47,16 @@ class Point:
@overload
def __init__(self) -> None: ...
@overload
def __init__(self, x: float, y: float) -> None: ...
def __init__(self, x: typing.SupportsFloat, y: typing.SupportsFloat) -> None: ...
def as_list(self) -> list[float]: ...
@overload
def distance_to(self, x: float, y: float) -> float: ...
def distance_to(self, x: typing.SupportsFloat, y: typing.SupportsFloat) -> float: ...
@overload
def distance_to(self, other: Point) -> float: ...
@property
def length(self) -> float: ...

def answer() -> int: ...
def midpoint(left: float, right: float) -> float: ...
def sum(arg0: int, arg1: int) -> int: ...
def weighted_midpoint(left: float, right: float, alpha: float = ...) -> float: ...
def midpoint(left: typing.SupportsFloat, right: typing.SupportsFloat) -> float: ...
def sum(arg0: typing.SupportsInt, arg1: typing.SupportsInt) -> int: ...
def weighted_midpoint(left: typing.SupportsFloat, right: typing.SupportsFloat, alpha: typing.SupportsFloat = ...) -> float: ...
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import pathlib
import typing
from . import demo as demo
from typing import overload

Expand All @@ -7,27 +8,27 @@ class StaticMethods:
"""Initialize self. See help(type(self)) for accurate signature."""
@overload
@staticmethod
def overloaded_static_method(value: int) -> int:
def overloaded_static_method(value: typing.SupportsInt) -> int:
"""overloaded_static_method(*args, **kwargs)
Overloaded function.

1. overloaded_static_method(value: int) -> int
1. overloaded_static_method(value: typing.SupportsInt) -> int

2. overloaded_static_method(value: float) -> float
2. overloaded_static_method(value: typing.SupportsFloat) -> float
"""
@overload
@staticmethod
def overloaded_static_method(value: float) -> float:
def overloaded_static_method(value: typing.SupportsFloat) -> float:
"""overloaded_static_method(*args, **kwargs)
Overloaded function.

1. overloaded_static_method(value: int) -> int
1. overloaded_static_method(value: typing.SupportsInt) -> int

2. overloaded_static_method(value: float) -> float
2. overloaded_static_method(value: typing.SupportsFloat) -> float
"""
@staticmethod
def some_static_method(a: int, b: int) -> int:
"""some_static_method(a: int, b: int) -> int
def some_static_method(a: typing.SupportsInt, b: typing.SupportsInt) -> int:
"""some_static_method(a: typing.SupportsInt, b: typing.SupportsInt) -> int

None
"""
Expand All @@ -46,10 +47,10 @@ class TestStruct:
def func_incomplete_signature(*args, **kwargs):
"""func_incomplete_signature() -> dummy_sub_namespace::HasNoBinding"""
def func_returning_optional() -> int | None:
"""func_returning_optional() -> Optional[int]"""
"""func_returning_optional() -> int | None"""
def func_returning_pair() -> tuple[int, float]:
"""func_returning_pair() -> Tuple[int, float]"""
def func_returning_path() -> os.PathLike:
"""func_returning_path() -> os.PathLike"""
"""func_returning_pair() -> tuple[int, float]"""
def func_returning_path() -> pathlib.Path:
"""func_returning_path() -> pathlib.Path"""
def func_returning_vector() -> list[float]:
"""func_returning_vector() -> List[float]"""
"""func_returning_vector() -> list[float]"""
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import typing
from typing import ClassVar, overload

PI: float
Expand All @@ -14,23 +15,23 @@ class Point:
__entries: ClassVar[dict] = ...
degree: ClassVar[Point.AngleUnit] = ...
radian: ClassVar[Point.AngleUnit] = ...
def __init__(self, value: int) -> None:
"""__init__(self: pybind11_fixtures.demo.Point.AngleUnit, value: int) -> None"""
def __init__(self, value: typing.SupportsInt) -> None:
"""__init__(self: pybind11_fixtures.demo.Point.AngleUnit, value: typing.SupportsInt) -> None"""
def __eq__(self, other: object) -> bool:
"""__eq__(self: object, other: object) -> bool"""
"""__eq__(self: object, other: object, /) -> bool"""
def __hash__(self) -> int:
"""__hash__(self: object) -> int"""
"""__hash__(self: object, /) -> int"""
def __index__(self) -> int:
"""__index__(self: pybind11_fixtures.demo.Point.AngleUnit) -> int"""
"""__index__(self: pybind11_fixtures.demo.Point.AngleUnit, /) -> int"""
def __int__(self) -> int:
"""__int__(self: pybind11_fixtures.demo.Point.AngleUnit) -> int"""
"""__int__(self: pybind11_fixtures.demo.Point.AngleUnit, /) -> int"""
def __ne__(self, other: object) -> bool:
"""__ne__(self: object, other: object) -> bool"""
"""__ne__(self: object, other: object, /) -> bool"""
@property
def name(self) -> str:
"""name(self: handle) -> str
"""name(self: object, /) -> str

name(self: handle) -> str
name(self: object, /) -> str
"""
@property
def value(self) -> int:
Expand All @@ -49,23 +50,23 @@ class Point:
inch: ClassVar[Point.LengthUnit] = ...
mm: ClassVar[Point.LengthUnit] = ...
pixel: ClassVar[Point.LengthUnit] = ...
def __init__(self, value: int) -> None:
"""__init__(self: pybind11_fixtures.demo.Point.LengthUnit, value: int) -> None"""
def __init__(self, value: typing.SupportsInt) -> None:
"""__init__(self: pybind11_fixtures.demo.Point.LengthUnit, value: typing.SupportsInt) -> None"""
def __eq__(self, other: object) -> bool:
"""__eq__(self: object, other: object) -> bool"""
"""__eq__(self: object, other: object, /) -> bool"""
def __hash__(self) -> int:
"""__hash__(self: object) -> int"""
"""__hash__(self: object, /) -> int"""
def __index__(self) -> int:
"""__index__(self: pybind11_fixtures.demo.Point.LengthUnit) -> int"""
"""__index__(self: pybind11_fixtures.demo.Point.LengthUnit, /) -> int"""
def __int__(self) -> int:
"""__int__(self: pybind11_fixtures.demo.Point.LengthUnit) -> int"""
"""__int__(self: pybind11_fixtures.demo.Point.LengthUnit, /) -> int"""
def __ne__(self, other: object) -> bool:
"""__ne__(self: object, other: object) -> bool"""
"""__ne__(self: object, other: object, /) -> bool"""
@property
def name(self) -> str:
"""name(self: handle) -> str
"""name(self: object, /) -> str

name(self: handle) -> str
name(self: object, /) -> str
"""
@property
def value(self) -> int:
Expand All @@ -84,25 +85,25 @@ class Point:

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

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

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

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

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

2. distance_to(self: pybind11_fixtures.demo.Point, other: pybind11_fixtures.demo.Point) -> float
"""
Expand All @@ -111,7 +112,7 @@ class Point:
"""distance_to(*args, **kwargs)
Overloaded function.

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

2. distance_to(self: pybind11_fixtures.demo.Point, other: pybind11_fixtures.demo.Point) -> float
"""
Expand All @@ -124,12 +125,12 @@ def answer() -> int:

answer docstring, with end quote"
'''
def midpoint(left: float, right: float) -> float:
"""midpoint(left: float, right: float) -> float"""
def sum(arg0: int, arg1: int) -> int:
'''sum(arg0: int, arg1: int) -> int
def midpoint(left: typing.SupportsFloat, right: typing.SupportsFloat) -> float:
"""midpoint(left: typing.SupportsFloat, right: typing.SupportsFloat) -> float"""
def sum(arg0: typing.SupportsInt, arg1: typing.SupportsInt) -> int:
'''sum(arg0: typing.SupportsInt, arg1: typing.SupportsInt) -> int

multiline docstring test, edge case quotes """\'\'\'
'''
def weighted_midpoint(left: float, right: float, alpha: float = ...) -> float:
"""weighted_midpoint(left: float, right: float, alpha: float = 0.5) -> float"""
def weighted_midpoint(left: typing.SupportsFloat, right: typing.SupportsFloat, alpha: typing.SupportsFloat = ...) -> float:
"""weighted_midpoint(left: typing.SupportsFloat, right: typing.SupportsFloat, alpha: typing.SupportsFloat = 0.5) -> float"""
2 changes: 1 addition & 1 deletion test-data/pybind11_fixtures/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ requires = [
"wheel",
# Officially supported pybind11 version. This is pinned to guarantee 100% reproducible CI.
# As a result, the version needs to be bumped manually at will.
"pybind11==2.9.2",
"pybind11==3.0.1",
]

build-backend = "setuptools.build_meta"