Skip to content

Commit 95dc843

Browse files
committed
🐴 workarounds for mypy...
1 parent f5579b5 commit 95dc843

3 files changed

Lines changed: 19 additions & 21 deletions

File tree

src/numpy-stubs/_core/numeric.pyi

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ def ones(
738738
# NOTE: The mypy [overload-overlap] errors are false-positives that are caused by a
739739
# bug that's related to constrained type-vars.
740740
@overload # 1d shape, known fill scalar-type
741-
def full( # type: ignore[overload-overlap]
741+
def full(
742742
shape: _ShapeLike1D,
743743
fill_value: _ScalarT,
744744
dtype: None = None,
@@ -748,7 +748,7 @@ def full( # type: ignore[overload-overlap]
748748
like: _SupportsArrayFunc | None = None,
749749
) -> _nt.Array1D[_ScalarT]: ...
750750
@overload # 1d shape, bool fill
751-
def full( # type: ignore[overload-overlap]
751+
def full(
752752
shape: _ShapeLike1D,
753753
fill_value: py_bool,
754754
dtype: None = None,
@@ -758,7 +758,7 @@ def full( # type: ignore[overload-overlap]
758758
like: _SupportsArrayFunc | None = None,
759759
) -> _nt.Array1D[np.bool]: ...
760760
@overload # 1d shape, int fill
761-
def full( # type: ignore[overload-overlap]
761+
def full(
762762
shape: _ShapeLike1D,
763763
fill_value: _nt.JustInt,
764764
dtype: None = None,
@@ -778,7 +778,7 @@ def full(
778778
like: _SupportsArrayFunc | None = None,
779779
) -> _nt.Array1D[np.float64]: ...
780780
@overload # 1d shape, complex fill
781-
def full( # type: ignore[overload-overlap]
781+
def full(
782782
shape: _ShapeLike1D,
783783
fill_value: _nt.JustComplex,
784784
dtype: None = None,
@@ -808,7 +808,7 @@ def full(
808808
like: _SupportsArrayFunc | None = None,
809809
) -> _nt.Array1D[_ScalarT]: ...
810810
@overload # 1d shape, float64 dtype
811-
def full( # type: ignore[overload-overlap]
811+
def full(
812812
shape: _ShapeLike1D,
813813
fill_value: object,
814814
dtype: _nt.ToDTypeFloat64,
@@ -918,7 +918,7 @@ def full(
918918
like: _SupportsArrayFunc | None = None,
919919
) -> _nt.Array[Any, _AnyShapeT]: ...
920920
@overload # unknown shape, known fill scalar-type
921-
def full( # type: ignore[overload-overlap]
921+
def full(
922922
shape: _ShapeLike,
923923
fill_value: _ScalarT,
924924
dtype: None = None,
@@ -928,7 +928,7 @@ def full( # type: ignore[overload-overlap]
928928
like: _SupportsArrayFunc | None = None,
929929
) -> _nt.Array[_ScalarT]: ...
930930
@overload # unknown shape, bool fill
931-
def full( # type: ignore[overload-overlap]
931+
def full(
932932
shape: _ShapeLike,
933933
fill_value: py_bool,
934934
dtype: None = None,
@@ -938,7 +938,7 @@ def full( # type: ignore[overload-overlap]
938938
like: _SupportsArrayFunc | None = None,
939939
) -> _nt.Array[np.bool]: ...
940940
@overload # unknown shape, int fill
941-
def full( # type: ignore[overload-overlap]
941+
def full(
942942
shape: _ShapeLike,
943943
fill_value: _nt.JustInt,
944944
dtype: None = None,
@@ -958,7 +958,7 @@ def full(
958958
like: _SupportsArrayFunc | None = None,
959959
) -> _nt.Array[np.float64]: ...
960960
@overload # unknown shape, complex fill
961-
def full( # type: ignore[overload-overlap]
961+
def full(
962962
shape: _ShapeLike,
963963
fill_value: _nt.JustComplex,
964964
dtype: None = None,

src/numpy-stubs/lib/_index_tricks_impl.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ def ix_(*args: _nt.SequenceND[_nt.JustComplex]) -> _Arrays[np.complex128]: ...
177177
def ix_(*args: _nt.SequenceND[_nt.JustBytes]) -> _Arrays[np.bytes_]: ...
178178
@overload
179179
def ix_(*args: _nt.SequenceND[_nt.JustStr]) -> _Arrays[np.str_]: ...
180+
@overload # the redundant overloads below are a workaround for a mypy bug
181+
def ix_(*args: _nt.SequenceND[int]) -> _Arrays[np.intp | np.bool]: ... # type: ignore[overload-cannot-match] # pyright: ignore[reportOverlappingOverload]
182+
@overload
183+
def ix_(*args: _nt.SequenceND[float]) -> _Arrays[np.float64 | np.intp | np.bool]: ... # type: ignore[overload-cannot-match] # pyright: ignore[reportOverlappingOverload]
184+
@overload
185+
def ix_(*args: _nt.SequenceND[complex]) -> _Arrays[np.complex128 | np.float64 | np.intp | np.bool]: ... # type: ignore[overload-cannot-match] # pyright: ignore[reportOverlappingOverload]
180186

181187
#
182188
def fill_diagonal(a: _nt.Array, val: Any, wrap: bool = False) -> None: ...

src/numpy-stubs/linalg/_linalg.pyi

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -845,9 +845,9 @@ def norm(
845845
@overload # float64 | complex128 | character, axis=<given> (positional)
846846
def norm(x: _ToUnsafe64_1nd, ord: _Ord | None, axis: _Ax2, keepdims: bool = False) -> _nt.Array[np.float64]: ... # type: ignore[overload-overlap]
847847
@overload # float64 | complex128 | character, axis=<given> (keyword)
848-
def norm(
848+
def norm( # type: ignore[overload-overlap]
849849
x: _ToUnsafe64_1nd, ord: _Ord | None = None, *, axis: _Ax2, keepdims: bool = False
850-
) -> _nt.Array[np.float64]: ... # type: ignore[overload-overlap]
850+
) -> _nt.Array[np.float64]: ...
851851
@overload # float16, axis=None, keepdims=False
852852
def norm(x: _nt.ToFloat16_1nd, ord: _Ord | None = None, axis: None = None, keepdims: _False = False) -> np.float16: ...
853853
@overload # float16, keepdims=True (keyword)
@@ -862,11 +862,7 @@ def norm(
862862
def norm(x: _Toinexact32_1nd, ord: _Ord | None = None, axis: None = None, keepdims: _False = False) -> np.float32: ...
863863
@overload # float32 | complex64, keepdims=True (keyword)
864864
def norm(
865-
x: _Toinexact32_1nd,
866-
ord: _Ord | None = None,
867-
axis: _Ax2 | None = None,
868-
*,
869-
keepdims: _True,
865+
x: _Toinexact32_1nd, ord: _Ord | None = None, axis: _Ax2 | None = None, *, keepdims: _True
870866
) -> _Array_2nd[np.float32]: ...
871867
@overload # float32 | complex64, axis=<given> (positional)
872868
def norm(x: _Toinexact32_1nd, ord: _Ord | None, axis: _Ax2, keepdims: bool = False) -> _nt.Array[np.float32]: ...
@@ -880,11 +876,7 @@ def norm(
880876
) -> np.longdouble: ...
881877
@overload # longdouble | clongdouble, keepdims=True (keyword)
882878
def norm(
883-
x: _Toinexact64l_1nd,
884-
ord: _Ord | None = None,
885-
axis: _Ax2 | None = None,
886-
*,
887-
keepdims: _True,
879+
x: _Toinexact64l_1nd, ord: _Ord | None = None, axis: _Ax2 | None = None, *, keepdims: _True
888880
) -> _Array_2nd[np.longdouble]: ...
889881
@overload # longdouble | clongdouble, axis=<given> (positional)
890882
def norm(x: _Toinexact64l_1nd, ord: _Ord | None, axis: _Ax2, keepdims: bool = False) -> _nt.Array[np.longdouble]: ...

0 commit comments

Comments
 (0)