From 26163af5ad8320d2c16de0723eea54758a9a43d5 Mon Sep 17 00:00:00 2001 From: Bhuvansh855 Date: Mon, 8 Jun 2026 17:28:47 +0530 Subject: [PATCH] docs: add concrete type definition and update protocol references --- docs/spec/concepts.rst | 11 +++++++++++ docs/spec/protocol.rst | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/docs/spec/concepts.rst b/docs/spec/concepts.rst index 81fe481fe..3b454e83d 100644 --- a/docs/spec/concepts.rst +++ b/docs/spec/concepts.rst @@ -169,6 +169,17 @@ is a subtype of ``str``, because ``MyStr`` represents a subset of the values represented by ``str``. Such types can be called "nominal types" and this is "nominal subtyping." +.. _`concrete-type`: + +Concrete types +-------------- + +A **concrete type** is a type specified by the name of a Python class, for +example, ``int``, ``str``, ``list``, or any user-defined class. Concrete types +represent actual Python objects and are distinct from protocols, type +variables, or type forms. They are used in type annotations where a specific +class is intended. + Other types (e.g. :ref:`Protocols` and :ref:`TypedDict`) instead describe a set of values by the types of their attributes and methods, or the types of their dictionary keys and values. These are called "structural types". A structural diff --git a/docs/spec/protocol.rst b/docs/spec/protocol.rst index 2803da0a6..3a132e502 100644 --- a/docs/spec/protocol.rst +++ b/docs/spec/protocol.rst @@ -385,8 +385,8 @@ Protocols cannot be instantiated, so there are no values whose runtime type is a protocol. For variables and parameters with protocol types, assignability relationships are subject to the following rules: -* A protocol is never assignable to a concrete type. -* A concrete type ``X`` is assignable to a protocol ``P`` if and only if ``X`` +* A protocol is never assignable to a :ref:`concrete-type`. +* A :ref:`concrete-type` ``X`` is assignable to a protocol ``P`` if and only if ``X`` implements all protocol members of ``P`` with assignable types. In other words, :term:`assignability ` with respect to a protocol is always :term:`structural`. @@ -465,7 +465,7 @@ Example:: ``type[]`` and class objects vs protocols ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Variables and parameters annotated with ``type[Proto]`` accept only concrete +Variables and parameters annotated with ``type[Proto]`` accept only :ref:`concrete-types ` (non-protocol) :term:`consistent subtypes ` of ``Proto``. The main reason for this is to allow instantiation of parameters with such types. For example::