##  7.14.  The ` type  ` statement  Â¶

    
    
    **type_stmt** ::=  'type' [identifier](lexical_analysis.html#grammar-token-python-grammar-identifier) [[type_params](compound_stmts.html#grammar-token-python-grammar-type_params)] "=" [expression](expressions.html#grammar-token-python-grammar-expression)
    

The ` type  ` statement declares a type alias, which is an instance of [ `
typing.TypeAliasType  ` ](../library/typing.html#typing.TypeAliasType
"typing.TypeAliasType") .

For example, the following statement creates a type alias:

    
    
    type Point = tuple[float, float]
    

This code is roughly equivalent to:

    
    
    annotation-def VALUE_OF_Point():
        return tuple[float, float]
    Point = typing.TypeAliasType("Point", VALUE_OF_Point())
    

` annotation-def  ` indicates an [ annotation scope
](executionmodel.html#annotation-scopes) , which behaves mostly like a
function, but with several small differences.

The value of the type alias is evaluated in the annotation scope. It is not
evaluated when the type alias is created, but only when the value is accessed
through the type aliasâs ` __value__  ` attribute (see [ Lazy evaluation
](executionmodel.html#lazy-evaluation) ). This allows the type alias to refer
to names that are not yet defined.

Type aliases may be made generic by adding a [ type parameter list
](compound_stmts.html#type-params) after the name. See [ Generic type aliases
](compound_stmts.html#generic-type-aliases) for more.

` type  ` is a [ soft keyword  ](lexical_analysis.html#soft-keywords) .

New in version 3.12.

See also

[ **PEP 695** ](https://peps.python.org/pep-0695/) \- Type Parameter Syntax

    

Introduced the ` type  ` statement and syntax for generic classes and
functions.

###  [ Table of Contents ](../contents.html)

  * 7\. Simple statements 
    * 7.1. Expression statements 
    * 7.2. Assignment statements 
      * 7.2.1. Augmented assignment statements 
      * 7.2.2. Annotated assignment statements 
    * 7.3. The ` assert  ` statement 
    * 7.4. The ` pass  ` statement 
    * 7.5. The ` del  ` statement 
    * 7.6. The ` return  ` statement 
    * 7.7. The ` yield  ` statement 
    * 7.8. The ` raise  ` statement 
    * 7.9. The ` break  ` statement 
    * 7.10. The ` continue  ` statement 
    * 7.11. The ` import  ` statement 
      * 7.11.1. Future statements 
    * 7.12. The ` global  ` statement 
    * 7.13. The ` nonlocal  ` statement 
    * 7.14. The ` type  ` statement 

####  Previous topic

[ 6\.  Expressions ](expressions.html "previous chapter")

####  Next topic

[ 8\.  Compound statements ](compound_stmts.html "next chapter")

###  This Page

  * [ Report a Bug ](../bugs.html)
  * [ Show Source ](https://github.com/python/cpython/blob/main/Doc/reference/simple_stmts.rst)

Â«

###  Navigation

  * [ index ](../genindex.html "General Index")
  * [ modules ](../py-modindex.html "Python Module Index") | 
  * [ next ](compound_stmts.html "8. Compound statements") | 
  * [ previous ](expressions.html "6. Expressions") | 
  * ![Python logo](../_static/py.svg)
  * [ Python ](https://www.python.org/) » 
  *   *   * [ 3.12.3 Documentation ](../index.html) » 
  * [ The Python Language Reference ](index.html) » 
  * [ 7\.  Simple statements ]()
  * | 
  * Theme  Auto  Light  Dark  | 

© [ Copyright ](../copyright.html) 2001-2024, Python Software Foundation.  
This page is licensed under the Python Software Foundation License Version 2.  
Examples, recipes, and other code in the documentation are additionally
licensed under the Zero Clause BSD License.  
See [ History and License ](/license.html) for more information.  
  
The Python Software Foundation is a non-profit corporation. [ Please donate.
](https://www.python.org/psf/donations/)  
  
Last updated on Apr 28, 2024 (09:58 UTC). [ Found a bug ](/bugs.html) ?  
Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.6.