-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[stubgenc] Render a bit better stubs (#9903)
* [stubgenc] Render classes before functions Functions may depend on class definitions, therefore should go after classes to not confuse some static analysis tools. A better solution (although way complex) would be a topological sort of all module elements (including variables) * [stubgenc] Show exact types for module attributes * [stubgenc] Show exact types for class attributes * [stubgenc] Shorten property return types (add necessary imports if needed) * [stubgenc] Support nested classes * [stubgenc] Don't render overloaded function umbrella (*args, **kwargs) signature Overloaded function header in pybind11 was erroneously recognized as an extra overload. * [stubgenc] Recognize pybind property return types Pybind includes function name in the property signature in docstrings * [stubgenc] Recognize pybind11 static properties * [stubgenc] Render rw-properties as annotated class attributes
- Loading branch information
Showing
4 changed files
with
138 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,62 @@ | ||
from typing import Any | ||
from typing import ClassVar | ||
|
||
from typing import overload | ||
PI: 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: ... | ||
|
||
class Point: | ||
AngleUnit: Any = ... | ||
LengthUnit: Any = ... | ||
origin: Any = ... | ||
class AngleUnit: | ||
__doc__: ClassVar[str] = ... # read-only | ||
__members__: ClassVar[dict] = ... # read-only | ||
__entries: ClassVar[dict] = ... | ||
degree: ClassVar[Point.AngleUnit] = ... | ||
radian: ClassVar[Point.AngleUnit] = ... | ||
def __init__(self, value: int) -> None: ... | ||
def __eq__(self, other: object) -> bool: ... | ||
def __getstate__(self) -> int: ... | ||
def __hash__(self) -> int: ... | ||
def __index__(self) -> int: ... | ||
def __int__(self) -> int: ... | ||
def __ne__(self, other: object) -> bool: ... | ||
def __setstate__(self, state: int) -> None: ... | ||
@property | ||
def name(self) -> str: ... | ||
|
||
class LengthUnit: | ||
__doc__: ClassVar[str] = ... # read-only | ||
__members__: ClassVar[dict] = ... # read-only | ||
__entries: ClassVar[dict] = ... | ||
inch: ClassVar[Point.LengthUnit] = ... | ||
mm: ClassVar[Point.LengthUnit] = ... | ||
pixel: ClassVar[Point.LengthUnit] = ... | ||
def __init__(self, value: int) -> None: ... | ||
def __eq__(self, other: object) -> bool: ... | ||
def __getstate__(self) -> int: ... | ||
def __hash__(self) -> int: ... | ||
def __index__(self) -> int: ... | ||
def __int__(self) -> int: ... | ||
def __ne__(self, other: object) -> bool: ... | ||
def __setstate__(self, state: int) -> None: ... | ||
@property | ||
def name(self) -> str: ... | ||
angle_unit: ClassVar[Point.AngleUnit] = ... | ||
length_unit: ClassVar[Point.LengthUnit] = ... | ||
x_axis: ClassVar[Point] = ... # read-only | ||
y_axis: ClassVar[Point] = ... # read-only | ||
origin: ClassVar[Point] = ... | ||
x: float | ||
y: float | ||
@overload | ||
def __init__(self) -> None: ... | ||
@overload | ||
def __init__(self, x: float, y: float) -> None: ... | ||
@overload | ||
def __init__(*args, **kwargs) -> Any: ... | ||
@overload | ||
def distance_to(self, x: float, y: float) -> float: ... | ||
@overload | ||
def distance_to(self, other: Point) -> float: ... | ||
@overload | ||
def distance_to(*args, **kwargs) -> Any: ... | ||
@property | ||
def angle_unit(self) -> pybind11_mypy_demo.basics.Point.AngleUnit: ... | ||
@angle_unit.setter | ||
def angle_unit(self, val: pybind11_mypy_demo.basics.Point.AngleUnit) -> None: ... | ||
@property | ||
def length(self) -> float: ... | ||
@property | ||
def length_unit(self) -> pybind11_mypy_demo.basics.Point.LengthUnit: ... | ||
@length_unit.setter | ||
def length_unit(self, val: pybind11_mypy_demo.basics.Point.LengthUnit) -> None: ... | ||
@property | ||
def x(self) -> float: ... | ||
@x.setter | ||
def x(self, val: float) -> None: ... | ||
@property | ||
def x_axis(self) -> pybind11_mypy_demo.basics.Point: ... | ||
@property | ||
def y(self) -> float: ... | ||
@y.setter | ||
def y(self, val: float) -> None: ... | ||
@property | ||
def y_axis(self) -> pybind11_mypy_demo.basics.Point: ... | ||
|
||
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: ... |