Skip to content

Commit fb812e7

Browse files
stroxlermeta-codesync[bot]
authored andcommitted
Keep SciPy shape-comment overloads compact
Summary: Put SciPy overload shape declarations between `overload` and `def` so Ruff preserves adjacent overloads, matching scipy-stubs formatting conventions. Leave NumPy examples, shape contracts, and the comment parser unchanged. Document the chosen placement in the SciPy demo. Differential Revision: D127646905
1 parent 96af5a7 commit fb812e7

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎tensor-shapes/comment-shape-corpus/scipy/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ maximize SciPy coverage.
5858
## Syntax observations
5959

6060
- The scalar `n: int # shaped: N` form is compact.
61+
- Overload declarations place `# shapes:` between `@overload` and `def`, so Ruff
62+
preserves adjacent overloads without inserting a blank line between them.
6163
- `.0` preserves dtype annotations. Splitting the type lets a shape comment
6264
sit directly beside `tuple[int, ...]` instead of using a long selector.
6365
- An `NDArray` alias hides the shape slot, requiring a full `= payload` replacement.

‎tensor-shapes/comment-shape-corpus/scipy/cholesky.pyi‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ def cho_factor(
4242
np.dtype[np.bool],
4343
],
4444
]: ...
45-
46-
# shapes: N
4745
@overload
46+
# shapes: N
4847
def cho_solve(
4948
c_and_lower: tuple[
5049
np.ndarray[tuple[int, int], np.dtype[np.float64]], # shaped: .0 = [N, N]
@@ -55,9 +54,8 @@ def cho_solve(
5554
check_finite: bool = True,
5655
) -> np.ndarray[tuple[int], np.dtype[np.float64]]: # shaped: .0 = [N]
5756
...
58-
59-
# shapes: N, K
6057
@overload
58+
# shapes: N, K
6159
def cho_solve(
6260
c_and_lower: tuple[
6361
np.ndarray[tuple[int, int], np.dtype[np.float64]], # shaped: .0 = [N, N]

0 commit comments

Comments
 (0)