chiark / gitweb /
documentation/python: reduce annotation test to just parsing, not links.
authorVladimír Vondruš <mosra@centrum.cz>
Sun, 14 Jul 2019 15:39:58 +0000 (17:39 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Sun, 14 Jul 2019 17:19:44 +0000 (19:19 +0200)
Type links are tested in test_inspect.TypeLinks.

documentation/test_python/inspect_annotations/inspect_annotations.Foo.html
documentation/test_python/inspect_annotations/inspect_annotations.html
documentation/test_python/inspect_annotations/inspect_annotations.py

index 7add22f86116da95b981e93f42b05ddc54ea4724..6ee52928ad973c4fd3532487765090d51e50d137 100644 (file)
             <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="#string_annotation" class="m-doc-self" id="string_annotation">string_annotation</a>(</span><span class="m-doc-wrap">self: <a href="inspect_annotations.Foo.html" class="m-doc">Foo</a>)</span>
-            </dt>
-            <dd>String annotations</dd>
-          </dl>
-        </section>
         <section id="properties">
           <h2><a href="#properties">Properties</a></h2>
           <dl class="m-doc">
index 82891543e8078bb2d616d21d3cc0d8022d60e43f..cc80ecf13d72d47558117bdb39a23bc4fe814340 100644 (file)
@@ -22,6 +22,7 @@
         <h1>
           inspect_annotations <span class="m-thin">module</span>
         </h1>
+        <p>Annotation parsing. For links inside annotations see test_inspect.TypeLinks.</p>
         <div class="m-block m-default">
           <h3>Contents</h3>
           <ul>
@@ -54,7 +55,7 @@
             <dt>
               <span class="m-doc-wrap-bumper">def <a href="#annotation" class="m-doc-self" id="annotation">annotation</a>(</span><span class="m-doc-wrap">param: typing.List[int],
               another: bool,
-              third: str = &#x27;hello&#x27;) -&gt; <a href="inspect_annotations.Foo.html" class="m-doc">Foo</a></span>
+              third: str = &#x27;hello&#x27;) -&gt; float</span>
             </dt>
             <dd>An annotated function</dd>
             <dt>
               <span class="m-doc-wrap-bumper">def <a href="#partial_annotation" class="m-doc-self" id="partial_annotation">partial_annotation</a>(</span><span class="m-doc-wrap">foo,
               param: typing.Tuple[int, int],
               unannotated,
-              cls: <a href="inspect_annotations.Foo.html" class="m-doc">Foo</a>)</span>
+              cls: object)</span>
             </dt>
             <dd>Partially annotated function</dd>
             <dt>
index 5a4ea25d39b29ee0d95bea7c0fdf941516403b49..27e8a3dab14359fc050cb166792a1e545df15818 100644 (file)
@@ -1,3 +1,5 @@
+"""Annotation parsing. For links inside annotations see test_inspect.TypeLinks."""
+
 import sys
 
 from typing import List, Tuple, Dict, Any, Union, Optional, Callable, TypeVar
@@ -10,13 +12,7 @@ class Foo:
         """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: 'Foo'):
-        """String annotations"""
-        pass
-
-def annotation(param: List[int], another: bool, third: str = "hello") -> Foo:
+def annotation(param: List[int], another: bool, third: str = "hello") -> float:
     """An annotated function"""
     pass
 
@@ -28,7 +24,7 @@ def no_annotation_default_param(param, another, third = "hello"):
     """Non-annotated function with a default parameter"""
     pass
 
-def partial_annotation(foo, param: Tuple[int, int], unannotated, cls: Foo):
+def partial_annotation(foo, param: Tuple[int, int], unannotated, cls: object):
     """Partially annotated function"""
     pass