<h3 dir="auto">Describe the issue:</h3>
<p dir="auto">Functions often accepts any ndarray as long as the elements are numbers. Using <code class="notranslate">npt.NDArray[np.number]</code> creates many mypy/pyright errors as none of the operators seems to be annotated for it.</p>
<h3 dir="auto">Reproduce the code example:</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np
import numpy.typing as npt

def foo(x: npt.NDArray[np.number]):
    x * 1
    x * x"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-k">import</span> <span class="pl-s1">numpy</span>.<span class="pl-s1">typing</span> <span class="pl-k">as</span> <span class="pl-s1">npt</span>

<span class="pl-k">def</span> <span class="pl-en">foo</span>(<span class="pl-s1">x</span>: <span class="pl-s1">npt</span>.<span class="pl-v">NDArray</span>[<span class="pl-s1">np</span>.<span class="pl-s1">number</span>]):
    <span class="pl-s1">x</span> <span class="pl-c1">*</span> <span class="pl-c1">1</span>
    <span class="pl-s1">x</span> <span class="pl-c1">*</span> <span class="pl-s1">x</span></pre></div>
<h3 dir="auto">Error message:</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="error: Unsupported operand types for * (&quot;ndarray[Any, dtype[number[Any]]]&quot; and &quot;int&quot;)  [operator]
error: Unsupported operand types for * (&quot;ndarray[Any, dtype[number[Any]]]&quot; and &quot;ndarray[Any, dtype[number[Any]]]&quot;)  [operator]"><pre class="notranslate">error: Unsupported operand types <span class="pl-k">for</span> <span class="pl-k">*</span> (<span class="pl-s"><span class="pl-pds">"</span>ndarray[Any, dtype[number[Any]]]<span class="pl-pds">"</span></span> and <span class="pl-s"><span class="pl-pds">"</span>int<span class="pl-pds">"</span></span>)  [operator]
error: Unsupported operand types <span class="pl-k">for</span> <span class="pl-k">*</span> (<span class="pl-s"><span class="pl-pds">"</span>ndarray[Any, dtype[number[Any]]]<span class="pl-pds">"</span></span> and <span class="pl-s"><span class="pl-pds">"</span>ndarray[Any, dtype[number[Any]]]<span class="pl-pds">"</span></span>)  [operator]</pre></div>
<h3 dir="auto">NumPy/Python version information:</h3>
<p dir="auto">1.22.3 3.10.2 (v3.10.2:a58ebcc, Mar 10 2022, 19:36:59) [GCC 9.4.0]</p>
<h3 dir="auto">Describe the issue:</h3>
<p dir="auto">Why operating on arrays typed as <code class="notranslate">npt.NDArray[np.number[Any]]</code>, the mypy plugin reports that <code class="notranslate">ndarray.__mul__</code> cannot accept argument type <code class="notranslate">int</code>.</p>
<p dir="auto">I would expect that an array of <code class="notranslate">np.number</code> can be multiplied by an integer.</p>
<h3 dir="auto">Reproduce the code example:</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# tmp.py
from typing import Any

import numpy as np
from numpy import typing as npt

arr: npt.NDArray[np.number[Any]] = np.array([1, 2])
arr * 3  # mypy error"><pre class="notranslate"><span class="pl-c"># tmp.py</span>
<span class="pl-k">from</span> <span class="pl-s1">typing</span> <span class="pl-k">import</span> <span class="pl-v">Any</span>

<span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-k">from</span> <span class="pl-s1">numpy</span> <span class="pl-k">import</span> <span class="pl-s1">typing</span> <span class="pl-k">as</span> <span class="pl-s1">npt</span>

<span class="pl-s1">arr</span>: <span class="pl-s1">npt</span>.<span class="pl-v">NDArray</span>[<span class="pl-s1">np</span>.<span class="pl-s1">number</span>[<span class="pl-v">Any</span>]] <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-c1">1</span>, <span class="pl-c1">2</span>])
<span class="pl-s1">arr</span> <span class="pl-c1">*</span> <span class="pl-c1">3</span>  <span class="pl-c"># mypy error</span></pre></div>
<p dir="auto">Running <code class="notranslate">mypy</code> on the above code gives an error.</p>
<h3 dir="auto">Error message:</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ mypy tmp.py
tmp.py:8: error: No overload variant of &quot;__mul__&quot; of &quot;ndarray&quot; matches argument type &quot;int&quot;
tmp.py:8: note: Possible overload variants:
tmp.py:8: note:     def __mul__(self, Union[str, bytes, Sequence[Union[str, bytes]], Sequence[Sequence[Union[str, bytes]]], Sequence[Sequence[Sequence[Union[str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[str, bytes]]]]]]) -&gt; NoReturn
tmp.py:8: note:     def __mul__(self, Union[_SupportsArray[dtype[object_]], Sequence[_SupportsArray[dtype[object_]]], Sequence[Sequence[_SupportsArray[dtype[object_]]]], Sequence[Sequence[Sequence[_SupportsArray[dtype[object_]]]]], Sequence[Sequence[Sequence[Sequence[_SupportsArray[dtype[object_]]]]]]]) -&gt; Any
tmp.py:8: note:     def __mul__(self, Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]]) -&gt; Any
Found 1 error in 1 file (checked 1 source file)"><pre lang="text" class="notranslate"><code class="notranslate">$ mypy tmp.py
tmp.py:8: error: No overload variant of "__mul__" of "ndarray" matches argument type "int"
tmp.py:8: note: Possible overload variants:
tmp.py:8: note:     def __mul__(self, Union[str, bytes, Sequence[Union[str, bytes]], Sequence[Sequence[Union[str, bytes]]], Sequence[Sequence[Sequence[Union[str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[str, bytes]]]]]]) -&gt; NoReturn
tmp.py:8: note:     def __mul__(self, Union[_SupportsArray[dtype[object_]], Sequence[_SupportsArray[dtype[object_]]], Sequence[Sequence[_SupportsArray[dtype[object_]]]], Sequence[Sequence[Sequence[_SupportsArray[dtype[object_]]]]], Sequence[Sequence[Sequence[Sequence[_SupportsArray[dtype[object_]]]]]]]) -&gt; Any
tmp.py:8: note:     def __mul__(self, Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]]) -&gt; Any
Found 1 error in 1 file (checked 1 source file)
</code></pre></div>
<h3 dir="auto">NumPy/Python version information:</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ mypy --version
mypy 0.910
$ python
Python 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 19:23:11)
[GCC 9.4.0] on linux
...
&gt;&gt;&gt; import numpy; print(numpy.__version__)
1.21.4"><pre lang="text" class="notranslate"><code class="notranslate">$ mypy --version
mypy 0.910
$ python
Python 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 19:23:11)
[GCC 9.4.0] on linux
...
&gt;&gt;&gt; import numpy; print(numpy.__version__)
1.21.4
</code></pre></div>