# TODO: why this is not None directly?
if annotation is inspect.Signature.empty: return None
+ # Annotations can be strings, also https://stackoverflow.com/a/33533514
+ if type(annotation) == str: return annotation
+
# To avoid getting <class 'foo.bar'> for types (and getting foo.bar
# instead) but getting the actual type for types annotated with e.g.
# List[int], we need to check if the annotation is actually from the
<li>
Reference
<ul>
+ <li><a href="#methods">Methods</a></li>
<li><a href="#properties">Properties</a></li>
</ul>
</li>
</ul>
</div>
+ <section id="methods">
+ <h2><a href="#methods">Methods</a></h2>
+ <dl class="m-doc">
+ <dt>
+ <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">string_annotation</a>(</span><span class="m-doc-wrap">self: inspect_annotations.Foo)</span>
+ </dt>
+ <dd>String annotations</dd>
+ </dl>
+ </section>
<section id="properties">
<h2><a href="#properties">Properties</a></h2>
<dl class="m-doc">
"""A property with a type annotation"""
pass
+ # Self-reference is only possible with a string in Py3
+ # https://stackoverflow.com/a/33533514
+ def string_annotation(self: 'inspect_annotations.Foo'):
+ """String annotations"""
+ pass
+
def annotation(param: List[int], another: bool, third: str = "hello") -> Foo:
"""An annotated function"""
pass