The "right" way is to use builtins when possible (e.g. dict over typing.Dict). typing.Dict is only needed if you use Python < 3.9. In older versions you couldn't use generic annotations like dict[str, Any] with builtins, you had to use Dict[str, Any]. See PEP 585

Answer from Expurple on Stack Overflow
🌐
Python documentation
docs.python.org › 3 › library › typing.html
typing — Support for type hints
1 week ago - Source code: Lib/typing.py This module provides runtime support for type hints. Consider the function below: The function surface_area_of_cube takes an argument expected to be an instance of float,...
🌐
Medium
medium.com › @moraneus › exploring-the-power-of-pythons-typing-library-ff32cec44981
Exploring the Power of Python’s typing Library | by Moraneus | Medium
May 17, 2024 - Python’s typing module has profoundly impacted the way developers author and comprehend Python code. This library brings a form of static type checking to a language historically known for its very dynamic nature.
Discussions

python - When/why use types from typing module for type hints - Stack Overflow
What is exactly the 'right' way for type hinting? My IDE (and resulting code) works fine for type hints using either of below options, but some types can be imported from the typing module. Is ther... More on stackoverflow.com
🌐 stackoverflow.com
Types in Python and the use of typing library
Actually, the typing library is now mostly unnecessary. When types were first introduced, you had to use classes from there for almost everything: although you could use int and float as you have above, if you wanted to type a parameter as a list of strings, for example, you had to do use List[str] from that library. Similarly, until Python 3.10 the only way to express a union - for example, a parameter could be an int or a float - was by using Union[int, float]. But now you can do int | float without using any of the typing classes. And the same for optional parameters - before you had to do Optional[str] but now you can do str | None. So, the main remaining uses for that library are specialised things like protocol classes, type variables, generic types, etc. More on reddit.com
🌐 r/learnpython
9
5
November 1, 2023
Why Type Hinting Sucks!
If you have a super-generic function like that and type hinting enforced, you just use Any and don't care about it. It's better than not type hinting your codebase at all, as in 99% of cases you can use the proper hints. Working in a big python codebase without type hints is a huge PIA. More on reddit.com
🌐 r/Python
290
935
February 13, 2023
Am I doing it wrong by writing my python code as if it's statically typed?
There's nothing wrong with type hinting, and I honestly cant imagine going back to the python days before type hinting was available At a minimum, I type hint all the function arguments and return types. Using good variable names helps a lot with what that variable type is More on reddit.com
🌐 r/learnpython
48
16
November 23, 2022
🌐
Real Python
realpython.com › ref › stdlib › typing
typing | Python Standard Library – Real Python
Python’s typing module provides tools for adding type hints to your code.
🌐
W3Schools
w3schools.com › python › ref_module_typing.asp
Python typing Module
The typing module provides support for type hints in Python code. Use it to add type annotations for better code documentation, IDE support, and static type checking with tools like mypy.
🌐
Python
typing.python.org › en › latest › guides › libraries.html
Typing Python Libraries — typing documentation
It’s possible to include a mix of type stub files (.pyi) and inline type annotations (.py). One use case for including type stub files in your package is to provide types for extension modules in your library.
🌐
FastAPI
fastapi.tiangolo.com › python-types
Python Types Intro - FastAPI
You can declare all the standard Python types, not only str. ... def get_items(item_a: str, item_b: int, item_c: float, item_d: bool, item_e: bytes): return item_a, item_b, item_c, item_d, item_e · For some additional use cases, you might need to import some things from the standard library typing module, for example when you want to declare that something has "any type", you can use Any from typing:
Find elsewhere
🌐
Python
docs.python.org › 3 › library › types.html
types — Dynamic type creation and names for built-in types
1 week ago - This module defines utility functions to assist in dynamic creation of new types. It also defines names for some object types that are used by the standard Python interpreter, but not exposed as builtins like int or str are.
🌐
OneUptime
oneuptime.com › blog › post › 2026-01-27-use-typing-module-type-annotations-python › view
How to Use typing Module for Type Annotations in Python
January 27, 2026 - # collection_types.py # Type annotations for collections from typing import List, Dict, Set, Tuple, Sequence # Lists with element type def get_names() -> List[str]: return ["Alice", "Bob", "Charlie"] def sum_numbers(numbers: List[int]) -> int: return sum(numbers) # Dictionaries with key and value types def get_user_ages() -> Dict[str, int]: return {"Alice": 30, "Bob": 25} def update_config(config: Dict[str, str]) -> None: config["updated"] = "true" # Sets def get_unique_tags() -> Set[str]: return {"python", "coding", "tutorial"} # Tuples - fixed length with specific types def get_coordinates()
🌐
YouTube
youtube.com › tech with tim
Python Typing - Type Hints & Annotations - YouTube
Welcome back to another video! In this video, I'll be covering content from the typing module in Python like type hints and annotations. The typing module al...
Published   September 29, 2021
Views   112K
🌐
PyPI
pypi.org › project › typing
typing · PyPI
Tags typing , function , annotations ... , typechecking , backport · Requires: Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <3.5 ... This project has been archived. The maintainers of this project have marked this project as archived. No new releases are expected. ... This is a backport of the standard library typing module to Python ...
      » pip install typing
    
Published   May 01, 2021
Version   3.10.0.0
🌐
GitHub
github.com › python › typing
GitHub - python/typing: Python static typing home. Hosts the documentation and a user help forum.
Python static typing home. Hosts the documentation and a user help forum. - python/typing
Starred by 1.7K users
Forked by 290 users
Languages   Python 84.3% | HTML 15.7%
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-typing-module
Python typing module - Use type checkers effectively | DigitalOcean
August 4, 2022 - Introduced since Python 3.5, Python’s typing module attempts to provide a way of hinting types to help static type checkers and linters accurately predict errors.
🌐
Reddit
reddit.com › r/learnpython › types in python and the use of typing library
r/learnpython on Reddit: Types in Python and the use of typing library
November 1, 2023 -

Greetings fellow humans,

I am using types in Python which now are supported natively as type hints.

Why and when should I use the typing library.

Code example:

def division(a: int, b: int) -> float:
  if b != 0:
    return a/b
  else:
    print("Division by zero is not allowed") 

In the above example I am using typing hints without the typing library.

Top answer
1 of 5
6
Actually, the typing library is now mostly unnecessary. When types were first introduced, you had to use classes from there for almost everything: although you could use int and float as you have above, if you wanted to type a parameter as a list of strings, for example, you had to do use List[str] from that library. Similarly, until Python 3.10 the only way to express a union - for example, a parameter could be an int or a float - was by using Union[int, float]. But now you can do int | float without using any of the typing classes. And the same for optional parameters - before you had to do Optional[str] but now you can do str | None. So, the main remaining uses for that library are specialised things like protocol classes, type variables, generic types, etc.
2 of 5
4
In more recent versions of Python, you need it less and less. Now that we can create type variables in 3.12 without it it only has a handful of uses left, mainly typing.Unpack for type hinting keyword arguments, or typing.NamedTuple which actually works differently from collections.namedtuple. Built-in collection types (list, tuple, collections.deque) have replaced their typing aliases (eg. typing.List), generics can now use the collections.abc counterparts, typing.Union and many similar ones have been replaced by operators, from __future__ import annotations means you don't need to worry about nested declarations, and so on. Basically, for the most part you don't need to touch it unless you want to support older versions, or you have specific needs. For example typing.assert_never is a relatively new addition which enables exhaustive checks of structural pattern matching: from enum import IntEnum, auto from typing import assert_never class WalkingState(IntEnum): STANDING = auto() WALKING = auto() RUNNING = auto() state = WalkingState.RUNNING match state: case WalkingState.STANDING: print("Standing") case WalkingState.WALKING: print("Walking") case _: assert_never(_) # We forgot to handle a case This will make the type checker scream at you until you've handled every option in the enum. Another example is the typing.TYPE_CHECKING constant, which is set to True when a type checker runs. This way you can, for example, only import things needed by the type checker without doing that at runtime. from typing import TYPE_CHECKING if TYPE_CHECKING: from collections.abc import Collection from numbers import Number def foo(nums: Collection[Number]) -> Number: return sum(nums) The last one in particular is something Ruff has drilled into my memory by now.
🌐
Medium
medium.com › @tssujith2002 › understanding-pythons-typing-module-and-its-importance-in-production-code-4113aada38a5
Understanding Python’s typing Module and Its Importance in Production Code | by sujith t s | Medium
May 30, 2025 - Reduces Debugging Time: Early mismatch detection cuts down production debugging efforts. The typing module is a powerful addition to Python that makes code safer, easier to understand, and more maintainable—critical factors in production ...
🌐
Medium
medium.com › @anuraagkhare_ › typing-module-deprecated-in-python-what-you-need-to-know-d4348b694141
“typing” Module Deprecated in Python: What You Need to Know | by Anuraag Khare | Medium
August 26, 2024 - However, as the language has grown, so has the need for more robust type hinting and annotations. The typing module, introduced in Python 3.5, played a significant role in bringing type hints to the language.
🌐
GeeksforGeeks
geeksforgeeks.org › python › introduction-to-python-typing-extensions-module
Introduction to Python Typing-Extensions Module - GeeksforGeeks
July 26, 2025 - The typing-extensions module is an essential library in Python that allows developers to use advanced type hinting features before they are officially added to the standard typing module.
🌐
PyPI
pypi.org › project › typing-extensions
typing-extensions · PyPI
Enable use of new type system features ... but typing_extensions allows users on previous Python versions to use it too. Enable experimentation with new type system PEPs before they are accepted and added to the typing module....
      » pip install typing-extensions
    
Published   Aug 25, 2025
Version   4.15.0
🌐
CodeSignal
codesignal.com › learn › courses › advanced-functional-programming-techniques-2 › lessons › advanced-typing-in-python
Advanced Typing in Python
You might wonder why we use List and Dict from the typing module when we can just use list and dict directly, such as list[int] or dict[str, int]. The typing module's List and Dict were introduced to provide a more consistent and explicit way of specifying types, especially before Python 3.9, ...