GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — TYP: Work around a mypy issue with bool arrays · numpy/numpy@0a180ad

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • numpy
    • __init__.pyi
    • typing/tests/data/reveal
      • array_constructors.pyi
      • ma.pyi
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎numpy/__init__.pyi‎

Copy file name to clipboardExpand all lines: numpy/__init__.pyi
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3846,14 +3846,14 @@ class bool(generic[_BoolItemT_co], Generic[_BoolItemT_co]):
38463846
@property
38473847
def imag(self) -> np.bool[L[False]]: ...
38483848

3849-
@overload
3850-
def __init__(self: np.bool[L[False]], /) -> None: ...
3849+
@overload # mypy bug workaround: https://github.com/numpy/numpy/issues/29245
3850+
def __init__(self: np.bool[builtins.bool], value: Never, /) -> None: ...
38513851
@overload
38523852
def __init__(self: np.bool[L[False]], value: _Falsy = ..., /) -> None: ...
38533853
@overload
38543854
def __init__(self: np.bool[L[True]], value: _Truthy, /) -> None: ...
38553855
@overload
3856-
def __init__(self, value: object, /) -> None: ...
3856+
def __init__(self: np.bool[builtins.bool], value: object, /) -> None: ...
38573857

38583858
def __bool__(self, /) -> _BoolItemT_co: ...
38593859
@overload
Collapse file

‎numpy/typing/tests/data/reveal/array_constructors.pyi‎

Copy file name to clipboardExpand all lines: numpy/typing/tests/data/reveal/array_constructors.pyi
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ assert_type(np.array(B, subok=True), SubClass[np.float64])
3939
assert_type(np.array(B, subok=True, ndmin=0), SubClass[np.float64])
4040
assert_type(np.array(B, subok=True, ndmin=1), SubClass[np.float64])
4141
assert_type(np.array(D), npt.NDArray[np.float64 | np.int64])
42+
# https://github.com/numpy/numpy/issues/29245
43+
assert_type(np.array([], dtype=np.bool), npt.NDArray[np.bool])
4244

4345
assert_type(np.zeros([1, 5, 6]), npt.NDArray[np.float64])
4446
assert_type(np.zeros([1, 5, 6], dtype=np.int64), npt.NDArray[np.int64])
Collapse file

‎numpy/typing/tests/data/reveal/ma.pyi‎

Copy file name to clipboardExpand all lines: numpy/typing/tests/data/reveal/ma.pyi
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,7 @@ assert_type(MAR_b.swapaxes(0, 1), MaskedArray[np.bool])
357357
assert_type(MAR_2d_f4.swapaxes(1, 0), MaskedArray[np.float32])
358358

359359
assert_type(np.ma.nomask, np.bool[Literal[False]])
360-
# https://github.com/python/mypy/issues/18974
361-
assert_type(np.ma.MaskType, type[np.bool]) # type: ignore[assert-type]
360+
assert_type(np.ma.MaskType, type[np.bool])
362361

363362
assert_type(MAR_1d.__setmask__([True, False]), None)
364363
assert_type(MAR_1d.__setmask__(np.False_), None)

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.