.. _UseTypesFromTypingRule:

======================
UseTypesFromTypingRule
======================

Enforces the use of types from the ``typing`` module in type annotations in place of ``builtins.{builtin_type}``
since the type system doesn't recognize the latter as a valid type.

----------------
Has Autofix: Yes
----------------

-------------------
VALID Code Examples
-------------------

# 1:







.. code-block:: python


    def fuction(list: List[str]) -> None:
        pass





# 2:







.. code-block:: python


    def function() -> None:
        thing: Dict[str, str] = {}





# 3:







.. code-block:: python


    def function() -> None:
        thing: Tuple[str]





.. container:: toggle


    # 4:







    .. code-block:: python


        from typing import Dict, List
        def function() -> bool:
                return Dict == List






    # 5:







    .. code-block:: python


        from typing import List as list
        from graphene import List

        def function(a: list[int]) -> List[int]:
                return []






---------------------
INVALID Code Examples
---------------------

# 1:







.. code-block:: python


    from typing import List
    def whatever(list: list[str]) -> None:
        pass





Autofix:

.. code-block:: python

    --- 
    +++ 
    @@ -1,4 +1,4 @@
 
     from typing import List
    -def whatever(list: list[str]) -> None:
    +def whatever(list: List[str]) -> None:
         pass

# 2:







.. code-block:: python


    def function(list: list[str]) -> None:
        pass





# 3:







.. code-block:: python


    def func() -> None:
        thing: dict[str, str] = {}





.. container:: toggle


    # 4:







    .. code-block:: python


        def func() -> None:
            thing: tuple[str]






    # 5:







    .. code-block:: python


        from typing import Dict
        def func() -> None:
            thing: dict[str, str] = {}





    Autofix:

    .. code-block:: python

        --- 
        +++ 
        @@ -1,4 +1,4 @@
 
         from typing import Dict
         def func() -> None:
        -    thing: dict[str, str] = {}
        +    thing: Dict[str, str] = {}

