File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -1458,6 +1458,23 @@ These can be used as types in annotations. They all support subscription using
14581458        >>> X.__metadata__ 
14591459        ('very', 'important', 'metadata') 
14601460
1461+    * At runtime, if you want to retrieve the original
1462+      type wrapped by ``Annotated ``, use the :attr: `!__origin__ ` attribute:
1463+ 
1464+      .. doctest ::
1465+ 
1466+         >>> from  typing import  Annotated, get_origin
1467+         >>> Password =  Annotated[str , " secret"  
1468+         >>> Password.__origin__ 
1469+         <class 'str'> 
1470+ 
1471+      Note that using :func: `get_origin ` will return ``Annotated `` itself:
1472+ 
1473+      .. doctest ::
1474+ 
1475+         >>> get_origin(Password) 
1476+         typing.Annotated 
1477+ 
14611478   .. seealso ::
14621479
14631480      :pep: `593 ` - Flexible function and variable annotations
@@ -3222,6 +3239,7 @@ Introspection helpers
32223239      assert get_origin(str) is None
32233240      assert get_origin(Dict[str, int]) is dict
32243241      assert get_origin(Union[int, str]) is Union
3242+       assert get_origin(Annotated[str, "metadata"]) is Annotated
32253243      P = ParamSpec('P')
32263244      assert get_origin(P.args) is P
32273245      assert get_origin(P.kwargs) is P
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments