`Iterable[(int, int)]` tuple is not allowed in type hints
<p>I have this very simple code:</p>

<pre><code>from typing import List, Iterable

Position = (int, int)
IntegerMatrix = List[List[int]]

def locate_zeros(matrix: IntegerMatrix) -&gt; Iterable[Position]:
    """Given an NxM matrix find the positions that contain a zero."""
    for row_num, row in enumerate(matrix):
        for col_num, element in enumerate(row):
            if element == 0:
                yield (col_num, row_num)
</code></pre>

<p>This is the error:</p>

<pre><code>Traceback (most recent call last):
  File "type_m.py", line 6, in &lt;module&gt;
    def locate_zeros(matrix: IntegerMatrix) -&gt; Iterable[Position]:
  File "/usr/lib/python3.5/typing.py", line 970, in __getitem__
    (len(self.__parameters__), len(params)))
TypeError: Cannot change parameter count from 1 to 2
</code></pre>

<p>Why can't I have an iterable of Int pairs as the return type?</p>

<p>Both <code>-&gt; Position</code> and <code>Iterable[Any]</code> work, just not <code>Iterable</code> and <code>Position</code> together don't.</p>

<p>You should use <code>typing.Tuple[int, int]</code> to declare the tuple type <code>Position</code>, not <code>(int, int)</code>.</p>

python python-3.5 typing