René's URL Explorer Experiment


Title: Python Type Checking (Guide) – Real Python

Open Graph Title: Python Type Checking (Guide) – Real Python

Description: In this guide, you'll look at Python type checking. Traditionally, types have been handled by the Python interpreter in a flexible but implicit way. Recent versions of Python allow you to specify explicit type hints that can be used by different tools to help you develop your code more efficiently.

Open Graph Description: In this guide, you'll look at Python type checking. Traditionally, types have been handled by the Python interpreter in a flexible but implicit way. Recent versions of Python allow you to specify explicit type hints that can be used by different tools to help you develop your code more efficiently.

Mail addresses
?subject=Python article for you&body=Python Type Checking (Guide) on Real Python https://realpython.com/python-type-checking/

Opengraph URL: https://realpython.com/python-type-checking/

X: @realpython

direct link

Domain: realpython.com


Hey, it has json ld scripts:
{
  "@context": "http://schema.org",
  "@type": "Article",
  "headline": "Python Type Checking (Guide)",
  "image": {
    "@type": "ImageObject",
    "url": "https://files.realpython.com/media/The-Ultimate-Guide-to-Python-Type-Checking_Watermarked.6fc1c7e40ada.jpg",
    "width": 1920,
    "height": 1080
  },
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "https://realpython.com/python-type-checking/",
    "lastReviewed": "2024-07-15",
    "author": {
      "@type": "Person",
      "name": "Geir Arne Hjelle",
      "image": "https://realpython.com/cdn-cgi/image/width=800,height=800,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/gahjelle.470149ee709e.jpg",
      "url": "https://realpython.com/team/gahjelle/",
      "affiliation": {
        "@type": "Organization",
        "@id": "https://realpython.com/#organization",
        "name": "Real Python",
        "url": "https://realpython.com",
        "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
      }
    },
    "reviewedBy": [
      {
        "@type": "Person",
        "name": "Aldren Santos",
        "image": "https://realpython.com/cdn-cgi/image/width=500,height=500,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Aldren_Santos_Real_Python.6b0861d8b841.png",
        "url": "https://realpython.com/team/asantos/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Brad Solomon",
        "image": "https://realpython.com/cdn-cgi/image/width=1188,height=1188,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Screen_Shot_2021-09-28_at_3.13.21_PM.3310c56e90bd.jpg",
        "url": "https://realpython.com/team/bsolomon/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Joanna Jablonski",
        "image": "https://realpython.com/cdn-cgi/image/width=800,height=800,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/jjablonksi-avatar.e37c4f83308e.jpg",
        "url": "https://realpython.com/team/jjablonski/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      }
    ]
  },
  "datePublished": "2019-01-07T14:00:00+00:00",
  "dateModified": "2024-07-15T06:12:07.994065+00:00",
  "publisher": {
    "@type": "Organization",
    "@id": "https://realpython.com/#organization",
    "name": "Real Python",
    "url": "https://realpython.com",
    "logo": {
      "@type": "ImageObject",
      "url": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png",
      "width": 512,
      "height": 512
    },
    "description": "Real Python is a leading provider of online Python education and one of the largest language-specific online communities for software developers. It publishes high-quality learning resources, such as tutorials, books, and courses to an audience of millions of developers, data scientists, and machine learning engineers each month.",
    "slogan": "Become a Python Expert",
    "email": "info@realpython.com",
    "sameAs": [
      "https://github.com/realpython",
      "https://www.youtube.com/realpython",
      "https://twitter.com/realpython",
      "https://x.com/realpython",
      "https://www.linkedin.com/company/realpython-com/",
      "https://www.facebook.com/learnrealpython",
      "https://www.instagram.com/realpython",
      "https://www.tiktok.com/@realpython.com"
    ]
  },
  "author": {
    "@type": "Person",
    "name": "Geir Arne Hjelle",
    "image": "https://realpython.com/cdn-cgi/image/width=800,height=800,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/gahjelle.470149ee709e.jpg",
    "url": "https://realpython.com/team/gahjelle/",
    "affiliation": {
      "@type": "Organization",
      "@id": "https://realpython.com/#organization",
      "name": "Real Python",
      "url": "https://realpython.com",
      "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
    }
  },
  "description": "In this guide, you'll look at Python type checking. Traditionally, types have been handled by the Python interpreter in a flexible but implicit way. Recent versions of Python allow you to specify explicit type hints that can be used by different tools to help you develop your code more efficiently."
}

authorReal Python
twitter:cardsummary_large_image
twitter:imagehttps://files.realpython.com/media/The-Ultimate-Guide-to-Python-Type-Checking_Watermarked.6fc1c7e40ada.jpg
og:imagehttps://files.realpython.com/media/The-Ultimate-Guide-to-Python-Type-Checking_Watermarked.6fc1c7e40ada.jpg
twitter:creator@realpython
og:typearticle

Links:

https://realpython.com/
Start Herehttps://realpython.com/start-here/
Learn Python https://realpython.com/python-type-checking/
Python Tutorials →In-depth articles and video courseshttps://realpython.com/search?kind=article&kind=course&order=newest
Learning Paths →Guided study plans for accelerated learninghttps://realpython.com/learning-paths/
Quizzes & Exercises →Check your learning progresshttps://realpython.com/quizzes/
Browse Topics →Focus on a specific area or skill levelhttps://realpython.com/tutorials/all/
Community Chat →Learn with other Pythonistashttps://realpython.com/community/
Office Hours →Live Q&A calls with Python expertshttps://realpython.com/office-hours/
Podcast →Hear what’s new in the world of Pythonhttps://realpython.com/podcasts/rpp/
Books →Round out your knowledge and learn offlinehttps://realpython.com/products/books/
Reference →Concise definitions for common Python termshttps://realpython.com/ref/
Code Mentor →BetaPersonalized code assistance & learning toolshttps://realpython.com/mentor/
Unlock All Content →https://realpython.com/account/join/
More https://realpython.com/python-type-checking/
Learner Storieshttps://realpython.com/learner-stories/
Python Newsletterhttps://realpython.com/newsletter/
Python Job Boardhttps://www.pythonjobshq.com
Meet the Teamhttps://realpython.com/team/
Become a Tutorial Writerhttps://realpython.com/write-for-us/
Become a Video Instructorhttps://realpython.com/become-an-instructor/
Searchhttps://realpython.com/search
https://realpython.com/search
Joinhttps://realpython.com/account/join/
Sign‑Inhttps://realpython.com/account/login/?next=%2Fpython-type-checking%2F
Browse Topicshttps://realpython.com/tutorials/all/
Guided Learning Pathshttps://realpython.com/learning-paths/
Basicshttps://realpython.com/search?level=basics
Intermediatehttps://realpython.com/search?level=intermediate
Advancedhttps://realpython.com/search?level=advanced
aihttps://realpython.com/tutorials/ai/
algorithmshttps://realpython.com/tutorials/algorithms/
apihttps://realpython.com/tutorials/api/
best-practiceshttps://realpython.com/tutorials/best-practices/
careerhttps://realpython.com/tutorials/career/
communityhttps://realpython.com/tutorials/community/
databaseshttps://realpython.com/tutorials/databases/
data-sciencehttps://realpython.com/tutorials/data-science/
data-structureshttps://realpython.com/tutorials/data-structures/
data-vizhttps://realpython.com/tutorials/data-viz/
devopshttps://realpython.com/tutorials/devops/
djangohttps://realpython.com/tutorials/django/
dockerhttps://realpython.com/tutorials/docker/
editorshttps://realpython.com/tutorials/editors/
flaskhttps://realpython.com/tutorials/flask/
front-endhttps://realpython.com/tutorials/front-end/
gamedevhttps://realpython.com/tutorials/gamedev/
guihttps://realpython.com/tutorials/gui/
machine-learninghttps://realpython.com/tutorials/machine-learning/
newshttps://realpython.com/tutorials/news/
numpyhttps://realpython.com/tutorials/numpy/
projectshttps://realpython.com/tutorials/projects/
pythonhttps://realpython.com/tutorials/python/
stdlibhttps://realpython.com/tutorials/stdlib/
testinghttps://realpython.com/tutorials/testing/
toolshttps://realpython.com/tutorials/tools/
web-devhttps://realpython.com/tutorials/web-dev/
web-scrapinghttps://realpython.com/tutorials/web-scraping/
Table of Contentshttps://realpython.com/python-type-checking/#toc
Type Systemshttps://realpython.com/python-type-checking/#type-systems
Dynamic Typinghttps://realpython.com/python-type-checking/#dynamic-typing
Static Typinghttps://realpython.com/python-type-checking/#static-typing
Duck Typinghttps://realpython.com/python-type-checking/#duck-typing
Hello Typeshttps://realpython.com/python-type-checking/#hello-types
Pros and Conshttps://realpython.com/python-type-checking/#pros-and-cons
Annotationshttps://realpython.com/python-type-checking/#annotations
Function Annotationshttps://realpython.com/python-type-checking/#function-annotations
Variable Annotationshttps://realpython.com/python-type-checking/#variable-annotations
Type Commentshttps://realpython.com/python-type-checking/#type-comments
So, Type Annotations or Type Comments?https://realpython.com/python-type-checking/#so-type-annotations-or-type-comments
Playing With Python Types, Part 1https://realpython.com/python-type-checking/#playing-with-python-types-part-1
Example: A Deck of Cardshttps://realpython.com/python-type-checking/#example-a-deck-of-cards
Sequences and Mappingshttps://realpython.com/python-type-checking/#sequences-and-mappings
Type Aliaseshttps://realpython.com/python-type-checking/#type-aliases
Functions Without Return Valueshttps://realpython.com/python-type-checking/#functions-without-return-values
Example: Play Some Cardshttps://realpython.com/python-type-checking/#example-play-some-cards
The Any Typehttps://realpython.com/python-type-checking/#the-any-type
Type Theoryhttps://realpython.com/python-type-checking/#type-theory
Subtypeshttps://realpython.com/python-type-checking/#subtypes
Covariant, Contravariant, and Invarianthttps://realpython.com/python-type-checking/#covariant-contravariant-and-invariant
Gradual Typing and Consistent Typeshttps://realpython.com/python-type-checking/#gradual-typing-and-consistent-types
Playing With Python Types, Part 2https://realpython.com/python-type-checking/#playing-with-python-types-part-2
Type Variableshttps://realpython.com/python-type-checking/#type-variables
Duck Types and Protocolshttps://realpython.com/python-type-checking/#duck-types-and-protocols
The Optional Typehttps://realpython.com/python-type-checking/#the-optional-type
Example: The Object(ive) of the Gamehttps://realpython.com/python-type-checking/#example-the-objective-of-the-game
Type Hints for Methodshttps://realpython.com/python-type-checking/#type-hints-for-methods
Classes as Typeshttps://realpython.com/python-type-checking/#classes-as-types
Returning self or clshttps://realpython.com/python-type-checking/#returning-self-or-cls
Annotating *args and **kwargshttps://realpython.com/python-type-checking/#annotating-args-and-kwargs
Callableshttps://realpython.com/python-type-checking/#callables
Example: Heartshttps://realpython.com/python-type-checking/#example-hearts
Static Type Checkinghttps://realpython.com/python-type-checking/#static-type-checking
The Mypy Projecthttps://realpython.com/python-type-checking/#the-mypy-project
Running Mypyhttps://realpython.com/python-type-checking/#running-mypy
Adding Stubshttps://realpython.com/python-type-checking/#adding-stubs
Typeshedhttps://realpython.com/python-type-checking/#typeshed
Other Static Type Checkershttps://realpython.com/python-type-checking/#other-static-type-checkers
Using Types at Runtimehttps://realpython.com/python-type-checking/#using-types-at-runtime
Conclusionhttps://realpython.com/python-type-checking/#conclusion
https://realpython.com/feedback/survey/article/python-type-checking/liked/?from=article-sidebar
https://realpython.com/feedback/survey/article/python-type-checking/disliked/?from=article-sidebar
Python Type Checkinghttps://realpython.com/courses/python-type-checking/
Geir Arne Hjellehttps://realpython.com/python-type-checking/#author
https://realpython.com/python-type-checking/#reader-comments
intermediatehttps://realpython.com/tutorials/intermediate/
best-practiceshttps://realpython.com/tutorials/best-practices/
Type Systemshttps://realpython.com/python-type-checking/#type-systems
Dynamic Typinghttps://realpython.com/python-type-checking/#dynamic-typing
Static Typinghttps://realpython.com/python-type-checking/#static-typing
Duck Typinghttps://realpython.com/python-type-checking/#duck-typing
Hello Typeshttps://realpython.com/python-type-checking/#hello-types
Pros and Conshttps://realpython.com/python-type-checking/#pros-and-cons
Annotationshttps://realpython.com/python-type-checking/#annotations
Function Annotationshttps://realpython.com/python-type-checking/#function-annotations
Variable Annotationshttps://realpython.com/python-type-checking/#variable-annotations
Type Commentshttps://realpython.com/python-type-checking/#type-comments
So, Type Annotations or Type Comments?https://realpython.com/python-type-checking/#so-type-annotations-or-type-comments
Playing With Python Types, Part 1https://realpython.com/python-type-checking/#playing-with-python-types-part-1
Example: A Deck of Cardshttps://realpython.com/python-type-checking/#example-a-deck-of-cards
Sequences and Mappingshttps://realpython.com/python-type-checking/#sequences-and-mappings
Type Aliaseshttps://realpython.com/python-type-checking/#type-aliases
Functions Without Return Valueshttps://realpython.com/python-type-checking/#functions-without-return-values
Example: Play Some Cardshttps://realpython.com/python-type-checking/#example-play-some-cards
The Any Typehttps://realpython.com/python-type-checking/#the-any-type
Type Theoryhttps://realpython.com/python-type-checking/#type-theory
Subtypeshttps://realpython.com/python-type-checking/#subtypes
Covariant, Contravariant, and Invarianthttps://realpython.com/python-type-checking/#covariant-contravariant-and-invariant
Gradual Typing and Consistent Typeshttps://realpython.com/python-type-checking/#gradual-typing-and-consistent-types
Playing With Python Types, Part 2https://realpython.com/python-type-checking/#playing-with-python-types-part-2
Type Variableshttps://realpython.com/python-type-checking/#type-variables
Duck Types and Protocolshttps://realpython.com/python-type-checking/#duck-types-and-protocols
The Optional Typehttps://realpython.com/python-type-checking/#the-optional-type
Example: The Object(ive) of the Gamehttps://realpython.com/python-type-checking/#example-the-objective-of-the-game
Type Hints for Methodshttps://realpython.com/python-type-checking/#type-hints-for-methods
Classes as Typeshttps://realpython.com/python-type-checking/#classes-as-types
Returning self or clshttps://realpython.com/python-type-checking/#returning-self-or-cls
Annotating *args and **kwargshttps://realpython.com/python-type-checking/#annotating-args-and-kwargs
Callableshttps://realpython.com/python-type-checking/#callables
Example: Heartshttps://realpython.com/python-type-checking/#example-hearts
Static Type Checkinghttps://realpython.com/python-type-checking/#static-type-checking
The Mypy Projecthttps://realpython.com/python-type-checking/#the-mypy-project
Running Mypyhttps://realpython.com/python-type-checking/#running-mypy
Adding Stubshttps://realpython.com/python-type-checking/#adding-stubs
Typeshedhttps://realpython.com/python-type-checking/#typeshed
Other Static Type Checkershttps://realpython.com/python-type-checking/#other-static-type-checkers
Using Types at Runtimehttps://realpython.com/python-type-checking/#using-types-at-runtime
Conclusionhttps://realpython.com/python-type-checking/#conclusion
Remove adshttps://realpython.com/account/join/
Python Type Checkinghttps://realpython.com/courses/python-type-checking/
Hello Typeshttps://realpython.com/python-type-checking/#hello-types
Pros and Conshttps://realpython.com/python-type-checking/#pros-and-cons
5 Thoughts On Python Masteryhttps://realpython.com/bonus/python-mastery-course/
https://realpython.com/quizzes/python-type-checking/
Python Type Checkinghttps://realpython.com/quizzes/python-type-checking/
https://realpython.com/python-type-checking/#type-systems
type systemhttps://en.wikipedia.org/wiki/Type_system
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-type-checking/#dynamic-typing
https://realpython.com/python-type-checking/#static-typing
Chttps://realpython.com/c-for-python-programmers/
Javahttps://realpython.com/oop-in-python-vs-java/
remain a dynamically typed languagehttps://www.python.org/dev/peps/pep-0484/#non-goals
PEP 484https://www.python.org/dev/peps/pep-0484/
you’ll see laterhttps://realpython.com/python-type-checking/#static-type-checking
https://realpython.com/python-type-checking/#duck-typing
duck typinghttps://en.wikipedia.org/wiki/Duck_typing
any of its variationshttps://en.wikipedia.org/wiki/Duck_test#History
strhttps://realpython.com/python-strings/
listhttps://realpython.com/python-list/
dicthttps://realpython.com/python-dicts/
structural subtypinghttps://en.wikipedia.org/wiki/Structural_type_system
more about duck typinghttps://realpython.com/python-type-checking/#duck-types-and-protocols
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-type-checking/#hello-types
terms of stylehttps://realpython.com/python-pep8/
PEP 8https://www.python.org/dev/peps/pep-0008/#other-recommendations
compares as truthyhttps://realpython.com/python-operators-expressions/#evaluation-of-non-boolean-values-in-boolean-context
PyCharmhttps://www.jetbrains.com/pycharm/
https://files.realpython.com/media/pycharm_type_error.76a49b9d4ff1.png
mypyhttp://mypy-lang.org/
laterhttps://realpython.com/python-type-checking/#the-mypy-project
Boolean valuehttps://realpython.com/python-boolean/
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-type-checking/#pros-and-cons
docstringshttps://realpython.com/documenting-python-code/
docstringshttps://realpython.com/how-to-write-docstrings-in-python/
PEP 257https://www.python.org/dev/peps/pep-0257/
https://files.realpython.com/media/pycharm_code_completion.82857c2750f6.png
multiple return typeshttps://realpython.com/python-type-hints-multiple-types/
debugginghttps://realpython.com/python-debugging-pdb/
type commentshttps://realpython.com/python-type-checking/#type-comments
variable annotationshttps://realpython.com/python-type-checking/#variable-annotations
postponed evaluation of type hintshttps://www.python.org/dev/peps/pep-0563/
Python 3.7https://realpython.com/python37-new-features/
typing modulehttps://realpython.com/python-type-checking/#sequences-and-mappings
importhttps://realpython.com/absolute-vs-relative-python-imports/
laterhttps://realpython.com/python-type-checking/#sequences-and-mappings
importhttps://realpython.com/python-import/
perf utilityhttps://perf.wiki.kernel.org/
Python 3.12 supportshttps://realpython.com/python312-perf-profiler/
faster startuphttps://docs.python.org/3/whatsnew/3.7.html#optimizations
gradual typinghttps://www.python.org/dev/peps/pep-0483/
short throw-away scriptshttps://www.youtube.com/watch?v=Jd8ulMb6_ls
published on PyPIhttps://realpython.com/pypi-publish-python-package/
cursive_rehttps://github.com/Bogdanp/cursive_re/blob/master/cursive_re/exprs.py
blackhttps://github.com/ambv/black/blob/master/black.py
Real Python Readerhttps://github.com/realpython/reader/blob/master/reader/feed.py
Mypyhttps://github.com/python/mypy/blob/master/mypy/build.py
The State of Type Hints in Pythonhttps://bernat.tech/posts/the-state-of-type-hints-in-python/
testshttps://realpython.com/python-testing/
https://realpython.com/python-type-checking/#annotations
introduced in Python 3.0https://www.python.org/dev/peps/pep-3107/
PEP 484https://www.python.org/dev/peps/pep-0484/
https://realpython.com/python-type-checking/#function-annotations
mypy version 0.610http://mypy-lang.blogspot.com/2018/06/mypy-0610-released.html
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-type-checking/#variable-annotations
PEP 526https://www.python.org/dev/peps/pep-0526/
https://realpython.com/python-type-checking/#type-comments
legacy Pythonhttps://pythonclock.org/
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-type-checking/#so-type-annotations-or-type-comments
officially recommended wayhttps://www.python.org/dev/peps/pep-0484/
linter directiveshttps://realpython.com/python-code-quality/
stub fileshttps://github.com/python/mypy/wiki/Creating-Stubs-For-Python-Modules
adding types to third party librarieshttps://realpython.com/python-type-checking/#adding-stubs
https://realpython.com/python-type-checking/#playing-with-python-types-part-1
sequences and mappingshttps://realpython.com/python-type-checking/#sequences-and-mappings
Type aliaseshttps://realpython.com/python-type-checking/#type-aliases
do not return anythinghttps://realpython.com/python-type-checking/#functions-without-return-values
any typehttps://realpython.com/python-type-checking/#the-any-type
type theoryhttps://realpython.com/python-type-checking/#type-theory
even more ways to specify types in Pythonhttps://realpython.com/python-type-checking/#playing-with-python-types-part-2
herehttps://github.com/realpython/materials/tree/master/python-type-checking
https://realpython.com/python-type-checking/#example-a-deck-of-cards
regular (French) deck of cardshttps://en.wikipedia.org/wiki/French_playing_cards
https://realpython.com/python-type-checking/#sequences-and-mappings
typing modulehttps://docs.python.org/library/typing.html
sequencehttps://docs.python.org/glossary.html#term-sequence
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-type-checking/#type-aliases
https://realpython.com/python-type-checking/#functions-without-return-values
Nonehttps://realpython.com/null-in-python/
NoReturnhttps://mypy.readthedocs.io/en/latest/more_types.html#the-noreturn-type
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-type-checking/#example-play-some-cards
card game examplehttps://realpython.com/python-type-checking/#example-a-deck-of-cards
https://realpython.com/python-type-checking/#the-any-type
https://realpython.com/python-type-checking/#type-theory
PEP 483https://www.python.org/dev/peps/pep-0483/
skip to the next sectionhttps://realpython.com/python-type-checking/#playing-with-python-types-part-2
https://realpython.com/python-type-checking/#subtypes
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-type-checking/#covariant-contravariant-and-invariant
covariant, contravariant, or invarianthttps://en.wikipedia.org/wiki/Covariance_and_contravariance_%28computer_science%29
laterhttps://realpython.com/python-type-checking/#callables
https://realpython.com/python-type-checking/#gradual-typing-and-consistent-types
gradual typinghttp://wphomes.soic.indiana.edu/jsiek/what-is-gradual-typing/
https://realpython.com/python-type-checking/#playing-with-python-types-part-2
Duck types and protocolshttps://realpython.com/python-type-checking/#duck-types-and-protocols
None as default valuehttps://realpython.com/python-type-checking/#the-optional-type
Class methodshttps://realpython.com/python-type-checking/#type-hints-for-methods
The type of your own classeshttps://realpython.com/python-type-checking/#classes-as-types
Variable number of argumentshttps://realpython.com/python-type-checking/#annotating-args-and-kwargs
https://realpython.com/python-type-checking/#type-variables
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-type-checking/#duck-types-and-protocols
the introductionhttps://realpython.com/python-type-checking/#duck-typing
structural subtypinghttps://en.wikipedia.org/wiki/Structural_type_system
PEP 544https://www.python.org/dev/peps/pep-0544/
implemented in mypyhttps://mypy.readthedocs.io/en/latest/protocols.html
examples of protocolshttps://mypy.readthedocs.io/en/latest/protocols.html#predefined-protocols
PyPIhttps://pypi.org/project/typing-extensions/
https://realpython.com/python-type-checking/#the-optional-type
mutable default valueshttps://docs.quantifiedcode.com/python-anti-patterns/correctness/mutable_default_value_as_argument.html
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-type-checking/#example-the-objective-of-the-game
object-orientedhttps://realpython.com/python3-object-oriented-programming/
https://realpython.com/python-type-checking/#type-hints-for-methods
https://realpython.com/python-type-checking/#classes-as-types
class methodhttps://realpython.com/instance-class-and-static-methods-demystified/
postponing the evaluation of annotationshttps://www.python.org/dev/peps/pep-0563/
Python 4.0http://www.curiousefficiency.org/posts/2014/08/python-4000.html
Python 3.7https://realpython.com/python37-new-features/
https://realpython.com/python-type-checking/#returning-self-or-cls
https://realpython.com/python-type-checking/#annotating-args-and-kwargs
object oriented versionhttps://realpython.com/python-type-checking/#example-the-objective-of-the-game
**kwargshttps://realpython.com/python-kwargs-and-args/
https://realpython.com/python-type-checking/#callables
first-class objectshttps://dbader.org/blog/python-first-class-functions
represented by typing.Callablehttps://mypy.readthedocs.io/en/latest/kinds_of_types.html#callable-types-and-lambdas
callback protocolshttps://mypy.readthedocs.io/en/latest/protocols.html#callback-protocols
extended callable typeshttps://mypy.readthedocs.io/en/latest/additional_features.html#extended-callable-types
https://realpython.com/python-type-checking/#example-hearts
Heartshttps://en.wikipedia.org/wiki/Hearts
found onlinehttps://www.bicyclecards.com/how-to-play/hearts
GitHubhttps://github.com/realpython/materials/tree/master/python-type-checking
the documentationhttps://mypy.readthedocs.io/en/latest/more_types.html#function-overloading
https://realpython.com/python-type-checking/#static-type-checking
https://realpython.com/python-type-checking/#the-mypy-project
Jukka’s slides from PyCon Finland 2012https://www.slideshare.net/jukkaleh/mypy-pyconfi2012
prominently visible on mypy’s home pagehttp://mypy-lang.org
suggestion by Guido van Rossumhttps://twitter.com/gvanrossum/status/700741601966985216
https://realpython.com/python-type-checking/#running-mypy
mypy command line documentation onlinehttps://mypy.readthedocs.io/en/stable/command_line.html#command-line
Numpyhttps://realpython.com/numpy-array-programming/
np.printoptions()https://docs.scipy.org/doc/numpy/reference/generated/numpy.printoptions.html
stubshttps://realpython.com/python-type-checking/#adding-stubs
typeshedhttps://realpython.com/python-type-checking/#typeshed
not try to follow or warn about any missing importshttps://mypy.readthedocs.io/en/stable/running_mypy.html#how-mypy-handles-imports
documentationhttps://mypy.readthedocs.io/en/stable/config_file.html
https://realpython.com/python-type-checking/#adding-stubs
Parse packagehttps://pypi.org/project/parse/
Parse is open sourcehttps://github.com/r1chardj0n3s/parse
stub filehttps://mypy.readthedocs.io/en/latest/stubs.html
ellipsis ...https://realpython.com/python-ellipsis/
https://realpython.com/python-type-checking/#typeshed
Typeshedhttps://github.com/python/typeshed
contribute type hints to Typeshedhttps://github.com/python/typeshed/blob/master/CONTRIBUTING.md
preferred approachhttps://github.com/python/typeshed/blob/master/CONTRIBUTING.md#adding-a-new-library
https://realpython.com/python-type-checking/#other-static-type-checkers
PyCharmhttps://realpython.com/python-ides-code-editors-guide/#pycharm
Pyrehttps://pyre-check.org/
documentationhttps://pyre-check.org/docs/overview.html
pytypehttps://github.com/google/pytype
quickstarthttps://github.com/google/pytype/blob/master/docs/quickstart.md
https://realpython.com/python-type-checking/#using-types-at-runtime
Enforcehttps://pypi.org/project/enforce/
Pydantichttps://pypi.org/project/pydantic/
Pytypeshttps://pypi.org/project/pytypes/
Cython projecthttps://cython.org/
Mypyc projecthttps://github.com/mypyc/mypyc
https://realpython.com/python-type-checking/#conclusion
PEP 483https://www.python.org/dev/peps/pep-0483/
PEP 484https://www.python.org/dev/peps/pep-0484/
mypy documentationhttps://mypy.readthedocs.io/
reference sectionhttps://mypy.readthedocs.io/en/stable/builtin_types.html
https://realpython.com/quizzes/python-type-checking/
Python Type Checkinghttps://realpython.com/quizzes/python-type-checking/
https://realpython.com/feedback/survey/article/python-type-checking/liked/?from=article-footer
https://realpython.com/feedback/survey/article/python-type-checking/disliked/?from=article-footer
Python Type Checkinghttps://realpython.com/courses/python-type-checking/
https://realpython.com/team/gahjelle/
» More about Geir Arnehttps://realpython.com/team/gahjelle/
https://realpython.com/team/asantos/
Aldrenhttps://realpython.com/team/asantos/
https://realpython.com/team/bsolomon/
Bradhttps://realpython.com/team/bsolomon/
https://realpython.com/team/jjablonski/
Joannahttps://realpython.com/team/jjablonski/
Level Up Your Python Skills »https://realpython.com/account/join/?utm_source=rp_article_footer&utm_content=python-type-checking
Level Up Your Python Skills »https://realpython.com/account/join/?utm_source=rp_article_footer&utm_content=python-type-checking
https://realpython.com/feedback/survey/article/python-type-checking/liked/?from=article-comments
https://realpython.com/feedback/survey/article/python-type-checking/disliked/?from=article-comments
LinkedInhttps://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Frealpython.com%2Fpython-type-checking%2F
Twitterhttps://twitter.com/intent/tweet/?text=Interesting%20Python%20article%20on%20%40realpython%3A%20Python%20Type%20Checking%20%28Guide%29&url=https%3A%2F%2Frealpython.com%2Fpython-type-checking%2F
Blueskyhttps://bsky.app/intent/compose?text=Interesting%20Python%20article%20on%20%40realpython.com%3A%20Python%20Type%20Checking%20%28Guide%29%20https%3A%2F%2Frealpython.com%2Fpython-type-checking%2F
Facebookhttps://facebook.com/sharer/sharer.php?u=https%3A%2F%2Frealpython.com%2Fpython-type-checking%2F
Get tips for asking good questionshttps://realpython.com/python-beginner-tips/#tip-9-ask-good-questions
get answers to common questions in our support portalhttps://support.realpython.com
Real Python Community Chathttps://realpython.com/community/
“Office Hours” Live Q&A Sessionhttps://realpython.com/office-hours/
intermediatehttps://realpython.com/tutorials/intermediate/
best-practiceshttps://realpython.com/tutorials/best-practices/
Python Type Checkinghttps://realpython.com/courses/python-type-checking/
Pydantic: Simplifying Data Validation in Pythonhttps://realpython.com/python-pydantic/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-type-checking
Data Classes in Python (Guide)https://realpython.com/python-data-classes/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-type-checking
Logging in Pythonhttps://realpython.com/python-logging/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-type-checking
Duck Typing in Python: Writing Flexible and Decoupled Codehttps://realpython.com/duck-typing-python/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-type-checking
Primer on Python Decoratorshttps://realpython.com/primer-on-python-decorators/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-type-checking
https://realpython.com/account/signup/?intent=continue_reading&utm_source=rp&utm_medium=web&utm_campaign=rwn&utm_content=v1&next=%2Fpython-type-checking%2F
Continue »https://realpython.com/account/signup/?intent=continue_reading&utm_source=rp&utm_medium=web&utm_campaign=rwn&utm_content=v1&next=%2Fpython-type-checking%2F
Sign-Inhttps://realpython.com/account/login/?next=/python-type-checking/
Start Herehttps://realpython.com/start-here/
Learning Resourceshttps://realpython.com/search
Code Mentorhttps://realpython.com/mentor/
Python Referencehttps://realpython.com/ref/
Python Cheat Sheethttps://realpython.com/cheatsheets/python/
Support Centerhttps://support.realpython.com/
Learning Pathshttps://realpython.com/learning-paths/
Quizzes & Exerciseshttps://realpython.com/quizzes/
Browse Topicshttps://realpython.com/tutorials/all/
Live Courseshttps://realpython.com/live/
Bookshttps://realpython.com/books/
Podcasthttps://realpython.com/podcasts/rpp/
Newsletterhttps://realpython.com/newsletter/
Community Chathttps://realpython.com/community/
Office Hourshttps://realpython.com/office-hours/
Learner Storieshttps://realpython.com/learner-stories/
Plans & Pricinghttps://realpython.com/account/join/
Team Planshttps://realpython.com/account/join-team/
For Businesshttps://realpython.com/account/join-team/inquiry/
For Schoolshttps://realpython.com/account/join-team/education-inquiry/
Reviewshttps://realpython.com/learner-stories/
About Ushttps://realpython.com/about/
Teamhttps://realpython.com/team/
Mission & Valueshttps://realpython.com/mission/
Editorial Guidelineshttps://realpython.com/editorial-guidelines/
Sponsorshipshttps://realpython.com/sponsorships/
Careershttps://realpython.workable.com
Press Kithttps://realpython.com/media-kit/
Merchhttps://realpython.com/merch
https://www.youtube.com/realpython
https://x.com/realpython
https://www.linkedin.com/company/realpython-com
https://www.facebook.com/LearnRealPython
https://github.com/realpython/
Privacy Policyhttps://realpython.com/privacy-policy/
Terms of Usehttps://realpython.com/terms/
Securityhttps://realpython.com/security/
Contacthttps://realpython.com/contact/
https://realpython.com/

Viewport: width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover

Robots: max-image-preview:large


URLs of crawlers that visited me.