What is the proper level of indent for hanging indent with type hinting in python?
<p>What is the proper syntax for a hanging indent for a method with multiple parameters and type hinting?</p>

<p><strong>Align under first parameter</strong></p>

<pre><code>def get_library_book(self,
                     book_id: str,
                     library_id: str
                     )-&gt; Book:
</code></pre>

<p><strong>Indent one level beneath</strong></p>

<pre><code>def get_library_book(
    self, 
    book_id: str, 
    library_id: str
) -&gt; Book:
</code></pre>

<p>PEP8 supports the <em>Indent one level beneath</em> case, but does not specify if <em>Align under first parameter</em> is allowed. It states: </p>

<blockquote>
  <p>When using a hanging indent the following should be considered; there
  should be no arguments on the first line and further indentation
  should be used to clearly distinguish itself as a continuation line.</p>
</blockquote>

<p>Appart from Terrys answer, take an example from <a href="https://github.com/python/typeshed" rel="nofollow"><code>typeshed</code></a> which is the project on Python's GitHub for annotating the <code>stdlib</code> with stubs. </p>

<p>For example, in <a href="https://github.com/python/typeshed/blob/master/stdlib/3/importlib/machinery.pyi" rel="nofollow"><code>importlib.machinery</code></a> (and in other cases if you look) annotations are done using your first form, <a href="https://github.com/python/typeshed/blob/master/stdlib/3/importlib/machinery.pyi#L16" rel="nofollow">for example</a>:</p>

<pre><code>def find_module(cls, fullname: str,
                path: Optional[Sequence[importlib.abc._Path]]
               ) -&gt; Optional[importlib.abc.Loader]:
</code></pre>

python python-3.x pep8 type-hinting