chunk_id
stringlengths
36
36
source
stringclasses
35 values
source_url
stringlengths
0
290
upstream_license
stringclasses
1 value
document_id
stringlengths
36
36
chunk_index
int64
0
324k
retrieved_at
stringclasses
2 values
chunker_version
stringclasses
4 values
content_hash
stringlengths
15
64
content
stringlengths
50
44.7k
namespace
stringclasses
9 values
source_name
stringclasses
35 values
raw_text
stringlengths
50
44.7k
cleaned_text
stringlengths
50
44.7k
tags
stringclasses
49 values
collection_name
stringclasses
11 values
a845d38c-78c8-4484-91fa-26a3da192f78
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,075
supabase-export-v2
68206b400df327c4
Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str}) This functional syntax allows defining keys which are not valid :ref:`identifiers <identifiers>`, for example because they are keywords or contain hyphens, or when key names must not be :ref:`mangled <private-name-mangling>` like regular private name...
trusted_official_docs
CPython Docs
Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str}) This functional syntax allows defining keys which are not valid :ref:`identifiers <identifiers>`, for example because they are keywords or contain hyphens, or when key names must not be :ref:`mangled <private-name-mangling>` like regular private name...
Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str}) This functional syntax allows defining keys which are not valid :ref:`identifiers <identifiers>`, for example because they are keywords or contain hyphens, or when key names must not be :ref:`mangled <private-name-mangling>` like regular private name...
python, official-docs, cpython, P0
Local_Trusted_Corpus
a92041ba-5fa6-4953-9ebb-6880464a9ab1
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,747
supabase-export-v2
190f1227de1a7785
Using ``-> TypeIs[NarrowedType]`` tells the static type checker that for a given function: 1. The return value is a boolean. 2. If the return value is ``True``, the type of its argument is the intersection of the argument's original type and ``NarrowedType``. 3. If the return value is ``False``, the type of its argume...
trusted_official_docs
CPython Docs
Using ``-> TypeIs[NarrowedType]`` tells the static type checker that for a given function: 1. The return value is a boolean. 2. If the return value is ``True``, the type of its argument is the intersection of the argument's original type and ``NarrowedType``. 3. If the return value is ``False``, the type of its argume...
Using ``-> TypeIs[NarrowedType]`` tells the static type checker that for a given function: 1. The return value is a boolean. 2. If the return value is ``True``, the type of its argument is the intersection of the argument's original type and ``NarrowedType``. 3. If the return value is ``False``, the type of its argume...
python, official-docs, cpython, P0
Local_Trusted_Corpus
a936f8ca-db85-4f58-9271-17320df596ca
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,361
supabase-export-v2
2d079e2d29995219
Deprecated alias to :class:`list`. Note that to annotate arguments, it is preferred to use an abstract collection type such as :class:`~collections.abc.Sequence` or :class:`~collections.abc.Iterable` rather than to use :class:`list` or :class:`!typing.List`.
trusted_official_docs
CPython Docs
Deprecated alias to :class:`list`. Note that to annotate arguments, it is preferred to use an abstract collection type such as :class:`~collections.abc.Sequence` or :class:`~collections.abc.Iterable` rather than to use :class:`list` or :class:`!typing.List`.
Deprecated alias to :class:`list`. Note that to annotate arguments, it is preferred to use an abstract collection type such as :class:`~collections.abc.Sequence` or :class:`~collections.abc.Iterable` rather than to use :class:`list` or :class:`!typing.List`.
python, official-docs, cpython, P0
Local_Trusted_Corpus
a9494c7a-04a1-4e07-bb08-160ae8df537f
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,222
supabase-export-v2
475c18d0112a504c
Decorator for creating overloaded functions and methods. The ``@overload`` decorator allows describing functions and methods that support multiple different combinations of argument types. A series of ``@overload``-decorated definitions must be followed by exactly one non-``@overload``-decorated definition (for the ...
trusted_official_docs
CPython Docs
Decorator for creating overloaded functions and methods. The ``@overload`` decorator allows describing functions and methods that support multiple different combinations of argument types. A series of ``@overload``-decorated definitions must be followed by exactly one non-``@overload``-decorated definition (for the ...
Decorator for creating overloaded functions and methods. The ``@overload`` decorator allows describing functions and methods that support multiple different combinations of argument types. A series of ``@overload``-decorated definitions must be followed by exactly one non-``@overload``-decorated definition (for the ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
ac2eab7c-526d-428e-adde-e98b9236958e
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,362
supabase-export-v2
46a1da064deb3ca9
that to annotate arguments, it is preferred to use an abstract collection type such as :class:`~collections.abc.Sequence` or :class:`~collections.abc.Iterable` rather than to use :class:`list` or :class:`!typing.List`. .. deprecated:: 3.9 :class:`builtins.list <list>` now supports subscripting (``[]``). See :pep:`585`...
trusted_official_docs
CPython Docs
that to annotate arguments, it is preferred to use an abstract collection type such as :class:`~collections.abc.Sequence` or :class:`~collections.abc.Iterable` rather than to use :class:`list` or :class:`!typing.List`. .. deprecated:: 3.9 :class:`builtins.list <list>` now supports subscripting (``[]``). See :pep:`585`...
that to annotate arguments, it is preferred to use an abstract collection type such as :class:`~collections.abc.Sequence` or :class:`~collections.abc.Iterable` rather than to use :class:`list` or :class:`!typing.List`. .. deprecated:: 3.9 :class:`builtins.list <list>` now supports subscripting (``[]``). See :pep:`585`...
python, official-docs, cpython, P0
Local_Trusted_Corpus
ac316429-cccb-4e41-ba84-68c96ad246fa
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,072
supabase-export-v2
f05ada307e873a24
a: Point2D = {'x': 1, 'y': 2, 'label': 'good'} # OK b: Point2D = {'z': 3, 'label': 'bad'} # Fails type check assert Point2D(x=1, y=2, label='first') == dict(x=1, y=2, label='first')
trusted_official_docs
CPython Docs
a: Point2D = {'x': 1, 'y': 2, 'label': 'good'} # OK b: Point2D = {'z': 3, 'label': 'bad'} # Fails type check assert Point2D(x=1, y=2, label='first') == dict(x=1, y=2, label='first')
a: Point2D = {'x': 1, 'y': 2, 'label': 'good'} # OK b: Point2D = {'z': 3, 'label': 'bad'} # Fails type check assert Point2D(x=1, y=2, label='first') == dict(x=1, y=2, label='first')
python, official-docs, cpython, P0
Local_Trusted_Corpus
ae13e736-1ce8-4528-9074-3d6cca1410bb
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,851
supabase-export-v2
0ee4845b47c50563
.. method:: evaluate_default An :term:`evaluate function` corresponding to the :attr:`~TypeVar.__default__` attribute. When called directly, this method supports only the :attr:`~annotationlib.Format.VALUE` format, which is equivalent to accessing the :attr:`~TypeVar.__default__` attribute directly, but the method ob...
trusted_official_docs
CPython Docs
.. method:: evaluate_default An :term:`evaluate function` corresponding to the :attr:`~TypeVar.__default__` attribute. When called directly, this method supports only the :attr:`~annotationlib.Format.VALUE` format, which is equivalent to accessing the :attr:`~TypeVar.__default__` attribute directly, but the method ob...
.. method:: evaluate_default An :term:`evaluate function` corresponding to the :attr:`~TypeVar.__default__` attribute. When called directly, this method supports only the :attr:`~annotationlib.Format.VALUE` format, which is equivalent to accessing the :attr:`~TypeVar.__default__` attribute directly, but the method ob...
python, official-docs, cpython, P0
Local_Trusted_Corpus
af7e872f-f970-406b-9fb3-77942dcea00b
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,813
supabase-export-v2
851601154e7b460f
have different semantics in several important ways. Using a *bounded* type variable means that the ``TypeVar`` will be solved using the most specific type possible:: x = print_capitalized('a string') reveal_type(x) # revealed type is str
trusted_official_docs
CPython Docs
have different semantics in several important ways. Using a *bounded* type variable means that the ``TypeVar`` will be solved using the most specific type possible:: x = print_capitalized('a string') reveal_type(x) # revealed type is str
have different semantics in several important ways. Using a *bounded* type variable means that the ``TypeVar`` will be solved using the most specific type possible:: x = print_capitalized('a string') reveal_type(x) # revealed type is str
python, official-docs, cpython, P0
Local_Trusted_Corpus
af93a4c6-597a-4f3d-bde2-0c99d0003778
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,366
supabase-export-v2
3cf11e42523dd07c
Note that to annotate arguments, it is preferred to use an abstract collection type such as :class:`collections.abc.Set` rather than to use :class:`set` or :class:`typing.Set`. .. deprecated:: 3.9 :class:`builtins.set <set>` now supports subscripting (``[]``). See :pep:`585` and :ref:`types-genericalias`.
trusted_official_docs
CPython Docs
Note that to annotate arguments, it is preferred to use an abstract collection type such as :class:`collections.abc.Set` rather than to use :class:`set` or :class:`typing.Set`. .. deprecated:: 3.9 :class:`builtins.set <set>` now supports subscripting (``[]``). See :pep:`585` and :ref:`types-genericalias`.
Note that to annotate arguments, it is preferred to use an abstract collection type such as :class:`collections.abc.Set` rather than to use :class:`set` or :class:`typing.Set`. .. deprecated:: 3.9 :class:`builtins.set <set>` now supports subscripting (``[]``). See :pep:`585` and :ref:`types-genericalias`.
python, official-docs, cpython, P0
Local_Trusted_Corpus
b0518990-4cb6-4163-96f5-084683cb41e5
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,853
supabase-export-v2
dccff97056c6e223
.. method:: has_default() Return whether or not the type variable has a default value. This is equivalent to checking whether :attr:`__default__` is not the :data:`typing.NoDefault` singleton, except that it does not force evaluation of the :ref:`lazily evaluated <lazy-evaluation>` default value.
trusted_official_docs
CPython Docs
.. method:: has_default() Return whether or not the type variable has a default value. This is equivalent to checking whether :attr:`__default__` is not the :data:`typing.NoDefault` singleton, except that it does not force evaluation of the :ref:`lazily evaluated <lazy-evaluation>` default value.
.. method:: has_default() Return whether or not the type variable has a default value. This is equivalent to checking whether :attr:`__default__` is not the :data:`typing.NoDefault` singleton, except that it does not force evaluation of the :ref:`lazily evaluated <lazy-evaluation>` default value.
python, official-docs, cpython, P0
Local_Trusted_Corpus
b0abc261-215d-4dac-b932-1fd1873a4a52
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,617
supabase-export-v2
5f760e080a3fad0e
a default. An optional argument with a default does not require the ``Optional`` qualifier on its type annotation just because it is optional. For example:: def foo(arg: int = 0) -> None: ...
trusted_official_docs
CPython Docs
a default. An optional argument with a default does not require the ``Optional`` qualifier on its type annotation just because it is optional. For example:: def foo(arg: int = 0) -> None: ...
a default. An optional argument with a default does not require the ``Optional`` qualifier on its type annotation just because it is optional. For example:: def foo(arg: int = 0) -> None: ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
b0de0678-9cf8-48e1-8655-4e646e4244e3
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,414
supabase-export-v2
9e0dd8957c9629b9
def new_non_team_user(user_class: type[BasicUser | ProUser]): ... new_non_team_user(BasicUser) # OK new_non_team_user(ProUser) # OK new_non_team_user(TeamUser) # Error: ``type[TeamUser]`` is not a subtype # of ``type[BasicUser | ProUser]`` new_non_team_user(User) # Also an error
trusted_official_docs
CPython Docs
def new_non_team_user(user_class: type[BasicUser | ProUser]): ... new_non_team_user(BasicUser) # OK new_non_team_user(ProUser) # OK new_non_team_user(TeamUser) # Error: ``type[TeamUser]`` is not a subtype # of ``type[BasicUser | ProUser]`` new_non_team_user(User) # Also an error
def new_non_team_user(user_class: type[BasicUser | ProUser]): ... new_non_team_user(BasicUser) # OK new_non_team_user(ProUser) # OK new_non_team_user(TeamUser) # Error: ``type[TeamUser]`` is not a subtype # of ``type[BasicUser | ProUser]`` new_non_team_user(User) # Also an error
python, official-docs, cpython, P0
Local_Trusted_Corpus
b21a82c6-909f-4ece-b99a-5e0ec5408664
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,325
supabase-export-v2
d0b4740686ebb5d6
Class used for internal typing representation of string forward references. For example, ``List["SomeClass"]`` is implicitly transformed into ``List[ForwardRef("SomeClass")]``. :class:`!ForwardRef` should not be instantiated by a user, but may be used by introspection tools.
trusted_official_docs
CPython Docs
Class used for internal typing representation of string forward references. For example, ``List["SomeClass"]`` is implicitly transformed into ``List[ForwardRef("SomeClass")]``. :class:`!ForwardRef` should not be instantiated by a user, but may be used by introspection tools.
Class used for internal typing representation of string forward references. For example, ``List["SomeClass"]`` is implicitly transformed into ``List[ForwardRef("SomeClass")]``. :class:`!ForwardRef` should not be instantiated by a user, but may be used by introspection tools.
python, official-docs, cpython, P0
Local_Trusted_Corpus
b26bcb8f-2ec0-40c4-8b47-e618f618eb3f
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,800
supabase-export-v2
c6e0d0df28a62291
The preferred way to construct a type variable is via the dedicated syntax for :ref:`generic functions <generic-functions>`, :ref:`generic classes <generic-classes>`, and :ref:`generic type aliases <generic-type-aliases>`:: class Sequence[T]: # T is a TypeVar ...
trusted_official_docs
CPython Docs
The preferred way to construct a type variable is via the dedicated syntax for :ref:`generic functions <generic-functions>`, :ref:`generic classes <generic-classes>`, and :ref:`generic type aliases <generic-type-aliases>`:: class Sequence[T]: # T is a TypeVar ...
The preferred way to construct a type variable is via the dedicated syntax for :ref:`generic functions <generic-functions>`, :ref:`generic classes <generic-classes>`, and :ref:`generic type aliases <generic-type-aliases>`:: class Sequence[T]: # T is a TypeVar ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
b2dbca68-c363-499c-9223-4f9e05639faa
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,762
supabase-export-v2
f1cc7799a478e247
1. The return value is a boolean. 2. If the return value is ``True``, the type of its argument is the type inside ``TypeGuard``. ``TypeGuard`` also works with type variables. See :pep:`647` for more details.
trusted_official_docs
CPython Docs
1. The return value is a boolean. 2. If the return value is ``True``, the type of its argument is the type inside ``TypeGuard``. ``TypeGuard`` also works with type variables. See :pep:`647` for more details.
1. The return value is a boolean. 2. If the return value is ``True``, the type of its argument is the type inside ``TypeGuard``. ``TypeGuard`` also works with type variables. See :pep:`647` for more details.
python, official-docs, cpython, P0
Local_Trusted_Corpus
b39d28cb-0879-47fc-99c0-b595c8b26b58
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,628
supabase-export-v2
e1d0fe58b26b0706
# Use this lock to ensure that only one thread is executing a function # at any time. my_lock = Lock() def with_lock[**P, R](f: Callable[Concatenate[Lock, P], R]) -> Callable[P, R]: '''A type-safe decorator which provides a lock.''' def inner(*args: P.args, **kwargs: P.kwargs) -> R: # Provide the lock as the first a...
trusted_official_docs
CPython Docs
# Use this lock to ensure that only one thread is executing a function # at any time. my_lock = Lock() def with_lock[**P, R](f: Callable[Concatenate[Lock, P], R]) -> Callable[P, R]: '''A type-safe decorator which provides a lock.''' def inner(*args: P.args, **kwargs: P.kwargs) -> R: # Provide the lock as the first a...
# Use this lock to ensure that only one thread is executing a function # at any time. my_lock = Lock() def with_lock[**P, R](f: Callable[Concatenate[Lock, P], R]) -> Callable[P, R]: '''A type-safe decorator which provides a lock.''' def inner(*args: P.args, **kwargs: P.kwargs) -> R: # Provide the lock as the first a...
python, official-docs, cpython, P0
Local_Trusted_Corpus
b3e26dab-e2b9-4ada-b8eb-f55a58d78b14
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,629
supabase-export-v2
d5864336acc49767
which provides a lock.''' def inner(*args: P.args, **kwargs: P.kwargs) -> R: # Provide the lock as the first argument. return f(my_lock, *args, **kwargs) return inner @with_lock def sum_threadsafe(lock: Lock, numbers: list[float]) -> float: '''Add a list of numbers together in a thread-safe manner.''' with lock: re...
trusted_official_docs
CPython Docs
which provides a lock.''' def inner(*args: P.args, **kwargs: P.kwargs) -> R: # Provide the lock as the first argument. return f(my_lock, *args, **kwargs) return inner @with_lock def sum_threadsafe(lock: Lock, numbers: list[float]) -> float: '''Add a list of numbers together in a thread-safe manner.''' with lock: re...
which provides a lock.''' def inner(*args: P.args, **kwargs: P.kwargs) -> R: # Provide the lock as the first argument. return f(my_lock, *args, **kwargs) return inner @with_lock def sum_threadsafe(lock: Lock, numbers: list[float]) -> float: '''Add a list of numbers together in a thread-safe manner.''' with lock: re...
python, official-docs, cpython, P0
Local_Trusted_Corpus
b4bd8b45-f30a-455f-b565-3710185dab65
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,216
supabase-export-v2
efa7e56fe1184dee
.. list-table:: **Recognised parameters for field specifiers** :header-rows: 1 :widths: 20 80 * - Parameter name - Description * - ``init`` - Indicates whether the field should be included in the synthesized ``__init__`` method. If unspecified, ``init`` defaults to ``True``. * - ``default`` - Provides the default...
trusted_official_docs
CPython Docs
.. list-table:: **Recognised parameters for field specifiers** :header-rows: 1 :widths: 20 80 * - Parameter name - Description * - ``init`` - Indicates whether the field should be included in the synthesized ``__init__`` method. If unspecified, ``init`` defaults to ``True``. * - ``default`` - Provides the default...
.. list-table:: **Recognised parameters for field specifiers** :header-rows: 1 :widths: 20 80 * - Parameter name - Description * - ``init`` - Indicates whether the field should be included in the synthesized ``__init__`` method. If unspecified, ``init`` defaults to ``True``. * - ``default`` - Provides the default...
python, official-docs, cpython, P0
Local_Trusted_Corpus
b4c778c5-4f85-47fe-9c8a-9accd4a22cfe
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,597
supabase-export-v2
b01ce3a63ac0cd33
Union type; ``Union[X, Y]`` is equivalent to ``X | Y`` and means either X or Y. To define a union, use e.g. ``Union[int, str]`` or the shorthand ``int | str``. Using that shorthand is recommended. Details:
trusted_official_docs
CPython Docs
Union type; ``Union[X, Y]`` is equivalent to ``X | Y`` and means either X or Y. To define a union, use e.g. ``Union[int, str]`` or the shorthand ``int | str``. Using that shorthand is recommended. Details:
Union type; ``Union[X, Y]`` is equivalent to ``X | Y`` and means either X or Y. To define a union, use e.g. ``Union[int, str]`` or the shorthand ``int | str``. Using that shorthand is recommended. Details:
python, official-docs, cpython, P0
Local_Trusted_Corpus
b4efd0b5-bc95-4b0f-8bd8-244c6f71f9c0
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,350
supabase-export-v2
d94b69ba123c5143
these generic classes using ``[]``. However, the aliases became redundant in Python 3.9 when the corresponding pre-existing classes were enhanced to support ``[]`` (see :pep:`585`). The redundant types are deprecated as of Python 3.9. However, while the aliases may be removed at some point, removal of these aliases is ...
trusted_official_docs
CPython Docs
these generic classes using ``[]``. However, the aliases became redundant in Python 3.9 when the corresponding pre-existing classes were enhanced to support ``[]`` (see :pep:`585`). The redundant types are deprecated as of Python 3.9. However, while the aliases may be removed at some point, removal of these aliases is ...
these generic classes using ``[]``. However, the aliases became redundant in Python 3.9 when the corresponding pre-existing classes were enhanced to support ``[]`` (see :pep:`585`). The redundant types are deprecated as of Python 3.9. However, while the aliases may be removed at some point, removal of these aliases is ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
b5d6e754-6af5-4d4f-b333-56764b4b1c90
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,784
supabase-export-v2
a1c5743f54e89b8e
The following classes should not be used directly as annotations. Their intended purpose is to be building blocks for creating generic types and type aliases. These objects can be created through special syntax (:ref:`type parameter lists <type-params>` and the :keyword:`type` statement). For compatibility with Python ...
trusted_official_docs
CPython Docs
The following classes should not be used directly as annotations. Their intended purpose is to be building blocks for creating generic types and type aliases. These objects can be created through special syntax (:ref:`type parameter lists <type-params>` and the :keyword:`type` statement). For compatibility with Python ...
The following classes should not be used directly as annotations. Their intended purpose is to be building blocks for creating generic types and type aliases. These objects can be created through special syntax (:ref:`type parameter lists <type-params>` and the :keyword:`type` statement). For compatibility with Python ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
b6024318-3ff2-44ad-acc5-301ca42a18d0
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,209
supabase-export-v2
7148efe6476a9879
:param bool order_default: Indicates whether the ``order`` parameter is assumed to be ``True`` or ``False`` if it is omitted by the caller. Defaults to ``False``. :param bool kw_only_default: Indicates whether the ``kw_only`` parameter is assumed to be ``True`` or ``False`` if it is omitted by the caller. Defaults to...
trusted_official_docs
CPython Docs
:param bool order_default: Indicates whether the ``order`` parameter is assumed to be ``True`` or ``False`` if it is omitted by the caller. Defaults to ``False``. :param bool kw_only_default: Indicates whether the ``kw_only`` parameter is assumed to be ``True`` or ``False`` if it is omitted by the caller. Defaults to...
:param bool order_default: Indicates whether the ``order`` parameter is assumed to be ``True`` or ``False`` if it is omitted by the caller. Defaults to ``False``. :param bool kw_only_default: Indicates whether the ``kw_only`` parameter is assumed to be ``True`` or ``False`` if it is omitted by the caller. Defaults to...
python, official-docs, cpython, P0
Local_Trusted_Corpus
b80f14b5-5414-4a4a-8c1a-ba4ba987313d
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,413
supabase-export-v2
f4b2ad7262f1b69d
.. versionadded:: 3.5.2 .. deprecated:: 3.11 Python 2 is no longer supported, and most type checkers also no longer support type checking Python 2 code. Removal of the alias is not currently planned, but users are encouraged to use :class:`str` instead of ``Text``.
trusted_official_docs
CPython Docs
.. versionadded:: 3.5.2 .. deprecated:: 3.11 Python 2 is no longer supported, and most type checkers also no longer support type checking Python 2 code. Removal of the alias is not currently planned, but users are encouraged to use :class:`str` instead of ``Text``.
.. versionadded:: 3.5.2 .. deprecated:: 3.11 Python 2 is no longer supported, and most type checkers also no longer support type checking Python 2 code. Removal of the alias is not currently planned, but users are encouraged to use :class:`str` instead of ``Text``.
python, official-docs, cpython, P0
Local_Trusted_Corpus
b8795eb4-9951-49e1-8654-d8bcd0b5ba92
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,760
supabase-export-v2
9bb93a81d260d125
their argument is an instance of a particular type. ``TypeGuard`` works similarly to :data:`TypeIs`, but has subtly different effects on type checking behavior (see below). Using ``-> TypeGuard`` tells the static type checker that for a given function:
trusted_official_docs
CPython Docs
their argument is an instance of a particular type. ``TypeGuard`` works similarly to :data:`TypeIs`, but has subtly different effects on type checking behavior (see below). Using ``-> TypeGuard`` tells the static type checker that for a given function:
their argument is an instance of a particular type. ``TypeGuard`` works similarly to :data:`TypeIs`, but has subtly different effects on type checking behavior (see below). Using ``-> TypeGuard`` tells the static type checker that for a given function:
python, official-docs, cpython, P0
Local_Trusted_Corpus
b8a73c41-5454-47ec-aacb-1341c34f9b98
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,332
supabase-export-v2
51652d86104408ca
you pass it. That means the expression ``Derived(some_value)`` does not create a new class or introduce much overhead beyond that of a regular function call. More precisely, the expression ``some_value is Derived(some_value)`` is always true at runtime.
trusted_official_docs
CPython Docs
you pass it. That means the expression ``Derived(some_value)`` does not create a new class or introduce much overhead beyond that of a regular function call. More precisely, the expression ``some_value is Derived(some_value)`` is always true at runtime.
you pass it. That means the expression ``Derived(some_value)`` does not create a new class or introduce much overhead beyond that of a regular function call. More precisely, the expression ``some_value is Derived(some_value)`` is always true at runtime.
python, official-docs, cpython, P0
Local_Trusted_Corpus
b8aa3eeb-2d57-47dd-8774-15b57ea69051
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,232
supabase-export-v2
9877de59a515b4b8
return a sequence of three function objects for the three defined overloads. If called on a function with no overloads, ``get_overloads()`` returns an empty sequence. ``get_overloads()`` can be used for introspecting an overloaded function at runtime.
trusted_official_docs
CPython Docs
return a sequence of three function objects for the three defined overloads. If called on a function with no overloads, ``get_overloads()`` returns an empty sequence. ``get_overloads()`` can be used for introspecting an overloaded function at runtime.
return a sequence of three function objects for the three defined overloads. If called on a function with no overloads, ``get_overloads()`` returns an empty sequence. ``get_overloads()`` can be used for introspecting an overloaded function at runtime.
python, official-docs, cpython, P0
Local_Trusted_Corpus
bcdd7382-800c-4bee-8b68-637873dd2626
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,176
supabase-export-v2
e804a5461598590d
infer that the last case can never execute, because ``arg`` is either an :class:`int` or a :class:`str`, and both options are covered by earlier cases. If a type checker finds that a call to ``assert_never()`` is reachable, it will emit an error. For example, if the type annotation for ``arg`` was instead ``int | str...
trusted_official_docs
CPython Docs
infer that the last case can never execute, because ``arg`` is either an :class:`int` or a :class:`str`, and both options are covered by earlier cases. If a type checker finds that a call to ``assert_never()`` is reachable, it will emit an error. For example, if the type annotation for ``arg`` was instead ``int | str...
infer that the last case can never execute, because ``arg`` is either an :class:`int` or a :class:`str`, and both options are covered by earlier cases. If a type checker finds that a call to ``assert_never()`` is reachable, it will emit an error. For example, if the type annotation for ``arg`` was instead ``int | str...
python, official-docs, cpython, P0
Local_Trusted_Corpus
bcecadc2-1a4b-4b3b-87e3-e22db97ec789
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,504
supabase-export-v2
ef0fc2872e57bae1
# A static type checker will treat the above # as having the same signature as: def legacy_parser(text: Any) -> Any: ... return data This behavior allows :data:`Any` to be used as an *escape hatch* when you need to mix dynamically and statically typed code.
trusted_official_docs
CPython Docs
# A static type checker will treat the above # as having the same signature as: def legacy_parser(text: Any) -> Any: ... return data This behavior allows :data:`Any` to be used as an *escape hatch* when you need to mix dynamically and statically typed code.
# A static type checker will treat the above # as having the same signature as: def legacy_parser(text: Any) -> Any: ... return data This behavior allows :data:`Any` to be used as an *escape hatch* when you need to mix dynamically and statically typed code.
python, official-docs, cpython, P0
Local_Trusted_Corpus
bd0f89d5-fb95-445d-8d28-d8d3deba47d4
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,773
supabase-export-v2
79abb250af1be9db
Ts = TypeVarTuple('Ts') tup: tuple[*Ts] # Effectively does: tup: tuple[Unpack[Ts]] In fact, ``Unpack`` can be used interchangeably with ``*`` in the context of :class:`typing.TypeVarTuple <TypeVarTuple>` and :class:`builtins.tuple <tuple>` types. You might see ``Unpack`` being used explicitly in older versions of Py...
trusted_official_docs
CPython Docs
Ts = TypeVarTuple('Ts') tup: tuple[*Ts] # Effectively does: tup: tuple[Unpack[Ts]] In fact, ``Unpack`` can be used interchangeably with ``*`` in the context of :class:`typing.TypeVarTuple <TypeVarTuple>` and :class:`builtins.tuple <tuple>` types. You might see ``Unpack`` being used explicitly in older versions of Py...
Ts = TypeVarTuple('Ts') tup: tuple[*Ts] # Effectively does: tup: tuple[Unpack[Ts]] In fact, ``Unpack`` can be used interchangeably with ``*`` in the context of :class:`typing.TypeVarTuple <TypeVarTuple>` and :class:`builtins.tuple <tuple>` types. You might see ``Unpack`` being used explicitly in older versions of Py...
python, official-docs, cpython, P0
Local_Trusted_Corpus
bdac52c6-3911-4aa9-9367-40bd77384774
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,875
supabase-export-v2
36357a9aef33fa22
Type variable tuples can be used in the same contexts as normal type variables. For example, in class definitions, arguments, and return types:: class Array[*Shape]: def __getitem__(self, key: tuple[*Shape]) -> float: ... def __abs__(self) -> "Array[*Shape]": ... def get_shape(self) -> tuple[*Shape]: ...
trusted_official_docs
CPython Docs
Type variable tuples can be used in the same contexts as normal type variables. For example, in class definitions, arguments, and return types:: class Array[*Shape]: def __getitem__(self, key: tuple[*Shape]) -> float: ... def __abs__(self) -> "Array[*Shape]": ... def get_shape(self) -> tuple[*Shape]: ...
Type variable tuples can be used in the same contexts as normal type variables. For example, in class definitions, arguments, and return types:: class Array[*Shape]: def __getitem__(self, key: tuple[*Shape]) -> float: ... def __abs__(self) -> "Array[*Shape]": ... def get_shape(self) -> tuple[*Shape]: ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
beb5d7df-9934-43f5-84dd-6c4386724ab8
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,087
supabase-export-v2
20c53d0623cc2887
literal ``False`` or ``True`` as the value of the ``total`` argument. ``True`` is the default, and makes all items defined in the class body required. Individual keys of a ``total=False`` ``TypedDict`` can be marked as required using :data:`Required`::
trusted_official_docs
CPython Docs
literal ``False`` or ``True`` as the value of the ``total`` argument. ``True`` is the default, and makes all items defined in the class body required. Individual keys of a ``total=False`` ``TypedDict`` can be marked as required using :data:`Required`::
literal ``False`` or ``True`` as the value of the ``total`` argument. ``True`` is the default, and makes all items defined in the class body required. Individual keys of a ``total=False`` ``TypedDict`` can be marked as required using :data:`Required`::
python, official-docs, cpython, P0
Local_Trusted_Corpus
bef55b68-5283-4f5d-81a9-f24844580028
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,370
supabase-export-v2
e5eed939971edb21
batch_proc([], good_cb) # OK batch_proc([], bad_cb) # Error! Argument 2 has incompatible type because of # different name and kind in the callback Callables which take other callables as arguments may indicate that their parameter types are dependent on each other using :class:`ParamSpec`. Additionally, if that callabl...
trusted_official_docs
CPython Docs
batch_proc([], good_cb) # OK batch_proc([], bad_cb) # Error! Argument 2 has incompatible type because of # different name and kind in the callback Callables which take other callables as arguments may indicate that their parameter types are dependent on each other using :class:`ParamSpec`. Additionally, if that callabl...
batch_proc([], good_cb) # OK batch_proc([], bad_cb) # Error! Argument 2 has incompatible type because of # different name and kind in the callback Callables which take other callables as arguments may indicate that their parameter types are dependent on each other using :class:`ParamSpec`. Additionally, if that callabl...
python, official-docs, cpython, P0
Local_Trusted_Corpus
c076f1b3-b66a-43bb-a30f-8b47be2fb4e8
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,822
supabase-export-v2
b7922b399df52927
Using a *constrained* type variable, however, means that the ``TypeVar`` can only ever be solved as being exactly one of the constraints given:: a = concatenate('one', 'two') reveal_type(a) # revealed type is str
trusted_official_docs
CPython Docs
Using a *constrained* type variable, however, means that the ``TypeVar`` can only ever be solved as being exactly one of the constraints given:: a = concatenate('one', 'two') reveal_type(a) # revealed type is str
Using a *constrained* type variable, however, means that the ``TypeVar`` can only ever be solved as being exactly one of the constraints given:: a = concatenate('one', 'two') reveal_type(a) # revealed type is str
python, official-docs, cpython, P0
Local_Trusted_Corpus
c15b4016-3fc3-44ca-b0ce-7d40acc181c7
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,301
supabase-export-v2
21e175bee48c1e84
Get type arguments with all substitutions performed: for a typing object of the form ``X[Y, Z, ...]`` return ``(Y, Z, ...)``. If ``X`` is a union or :class:`Literal` contained in another generic type, the order of ``(Y, Z, ...)`` may be different from the order of the original arguments ``[Y, Z, ...]`` due to type ca...
trusted_official_docs
CPython Docs
Get type arguments with all substitutions performed: for a typing object of the form ``X[Y, Z, ...]`` return ``(Y, Z, ...)``. If ``X`` is a union or :class:`Literal` contained in another generic type, the order of ``(Y, Z, ...)`` may be different from the order of the original arguments ``[Y, Z, ...]`` due to type ca...
Get type arguments with all substitutions performed: for a typing object of the form ``X[Y, Z, ...]`` return ``(Y, Z, ...)``. If ``X`` is a union or :class:`Literal` contained in another generic type, the order of ``(Y, Z, ...)`` may be different from the order of the original arguments ``[Y, Z, ...]`` due to type ca...
python, official-docs, cpython, P0
Local_Trusted_Corpus
c25c4f08-b630-4772-99a8-c9e7372b840c
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,351
supabase-export-v2
1ef7dacc827a420c
at some point, removal of these aliases is not currently planned. As such, no deprecation warnings are currently issued by the interpreter for these aliases. If at some point it is decided to remove these deprecated aliases, a deprecation warning will be issued by the interpreter for at least two releases prior to remo...
trusted_official_docs
CPython Docs
at some point, removal of these aliases is not currently planned. As such, no deprecation warnings are currently issued by the interpreter for these aliases. If at some point it is decided to remove these deprecated aliases, a deprecation warning will be issued by the interpreter for at least two releases prior to remo...
at some point, removal of these aliases is not currently planned. As such, no deprecation warnings are currently issued by the interpreter for these aliases. If at some point it is decided to remove these deprecated aliases, a deprecation warning will be issued by the interpreter for at least two releases prior to remo...
python, official-docs, cpython, P0
Local_Trusted_Corpus
c2d3d6de-df18-4976-b6f9-cf49d26e8d22
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,118
supabase-export-v2
9ea94ffc4941464d
.. doctest:: >>> class Point2D(TypedDict, total=False): ... x: int ... y: int ... >>> class Point3D(Point2D): ... z: int ... >>> Point3D.__required_keys__ == frozenset({'z'}) True >>> Point3D.__optional_keys__ == frozenset({'x', 'y'}) True
trusted_official_docs
CPython Docs
.. doctest:: >>> class Point2D(TypedDict, total=False): ... x: int ... y: int ... >>> class Point3D(Point2D): ... z: int ... >>> Point3D.__required_keys__ == frozenset({'z'}) True >>> Point3D.__optional_keys__ == frozenset({'x', 'y'}) True
.. doctest:: >>> class Point2D(TypedDict, total=False): ... x: int ... y: int ... >>> class Point3D(Point2D): ... z: int ... >>> Point3D.__required_keys__ == frozenset({'z'}) True >>> Point3D.__optional_keys__ == frozenset({'x', 'y'}) True
python, official-docs, cpython, P0
Local_Trusted_Corpus
c3f0b67c-554d-426c-b72c-74cff0de5ff2
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,514
supabase-export-v2
191a2eefafdb5784
subtyping*. This means that a class ``A`` is allowed where a class ``B`` is expected if and only if ``A`` is a subclass of ``B``. This requirement previously also applied to abstract base classes, such as :class:`~collections.abc.Iterable`. The problem with this approach is that a class had to be explicitly marked to s...
trusted_official_docs
CPython Docs
subtyping*. This means that a class ``A`` is allowed where a class ``B`` is expected if and only if ``A`` is a subclass of ``B``. This requirement previously also applied to abstract base classes, such as :class:`~collections.abc.Iterable`. The problem with this approach is that a class had to be explicitly marked to s...
subtyping*. This means that a class ``A`` is allowed where a class ``B`` is expected if and only if ``A`` is a subclass of ``B``. This requirement previously also applied to abstract base classes, such as :class:`~collections.abc.Iterable`. The problem with this approach is that a class had to be explicitly marked to s...
python, official-docs, cpython, P0
Local_Trusted_Corpus
c41f347a-1413-4b4e-930e-1231f3600de4
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,805
supabase-export-v2
d3c314761919d6d6
However, if desired, reusable type variables can also be constructed manually, like so:: T = TypeVar('T') # Can be anything S = TypeVar('S', bound=str) # Can be any subtype of str A = TypeVar('A', str, bytes) # Must be exactly str or bytes
trusted_official_docs
CPython Docs
However, if desired, reusable type variables can also be constructed manually, like so:: T = TypeVar('T') # Can be anything S = TypeVar('S', bound=str) # Can be any subtype of str A = TypeVar('A', str, bytes) # Must be exactly str or bytes
However, if desired, reusable type variables can also be constructed manually, like so:: T = TypeVar('T') # Can be anything S = TypeVar('S', bound=str) # Can be any subtype of str A = TypeVar('A', str, bytes) # Must be exactly str or bytes
python, official-docs, cpython, P0
Local_Trusted_Corpus
c4b6b581-6b2d-4434-b0f7-e7f75ef365fe
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,505
supabase-export-v2
2f53de5901a62a99
This behavior allows :data:`Any` to be used as an *escape hatch* when you need to mix dynamically and statically typed code. Contrast the behavior of :data:`Any` with the behavior of :class:`object`. Similar to :data:`Any`, every type is a subtype of :class:`object`. However, unlike :data:`Any`, the reverse is not true...
trusted_official_docs
CPython Docs
This behavior allows :data:`Any` to be used as an *escape hatch* when you need to mix dynamically and statically typed code. Contrast the behavior of :data:`Any` with the behavior of :class:`object`. Similar to :data:`Any`, every type is a subtype of :class:`object`. However, unlike :data:`Any`, the reverse is not true...
This behavior allows :data:`Any` to be used as an *escape hatch* when you need to mix dynamically and statically typed code. Contrast the behavior of :data:`Any` with the behavior of :class:`object`. Similar to :data:`Any`, every type is a subtype of :class:`object`. However, unlike :data:`Any`, the reverse is not true...
python, official-docs, cpython, P0
Local_Trusted_Corpus
c5f5d8c8-a0b8-47e2-907a-d4e051863395
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,245
supabase-export-v2
67f1bd896f6b922b
.. versionadded:: 3.8 .. versionchanged:: 3.11 The decorator will now attempt to set a ``__final__`` attribute to ``True`` on the decorated object. Thus, a check like ``if getattr(obj, "__final__", False)`` can be used at runtime to determine whether an object ``obj`` has been marked as final. If the decorated obje...
trusted_official_docs
CPython Docs
.. versionadded:: 3.8 .. versionchanged:: 3.11 The decorator will now attempt to set a ``__final__`` attribute to ``True`` on the decorated object. Thus, a check like ``if getattr(obj, "__final__", False)`` can be used at runtime to determine whether an object ``obj`` has been marked as final. If the decorated obje...
.. versionadded:: 3.8 .. versionchanged:: 3.11 The decorator will now attempt to set a ``__final__`` attribute to ``True`` on the decorated object. Thus, a check like ``if getattr(obj, "__final__", False)`` can be used at runtime to determine whether an object ``obj`` has been marked as final. If the decorated obje...
python, official-docs, cpython, P0
Local_Trusted_Corpus
c65c99ac-9bd0-447a-a293-832985926aa1
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,259
supabase-export-v2
199635d97a2be4fa
has been marked as an override. If the decorated object does not support setting attributes, the decorator returns the object unchanged without raising an exception. See :pep:`698` for more details.
trusted_official_docs
CPython Docs
has been marked as an override. If the decorated object does not support setting attributes, the decorator returns the object unchanged without raising an exception. See :pep:`698` for more details.
has been marked as an override. If the decorated object does not support setting attributes, the decorator returns the object unchanged without raising an exception. See :pep:`698` for more details.
python, official-docs, cpython, P0
Local_Trusted_Corpus
c737f7fb-dfcf-4a8e-bf6c-d3fc8949dfc8
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,771
supabase-export-v2
3d8c9f0cc75fdb5b
Typing operator to conceptually mark an object as having been unpacked. For example, using the unpack operator ``*`` on a :ref:`type variable tuple <typevartuple>` is equivalent to using ``Unpack`` to mark the type variable tuple as having been unpacked::
trusted_official_docs
CPython Docs
Typing operator to conceptually mark an object as having been unpacked. For example, using the unpack operator ``*`` on a :ref:`type variable tuple <typevartuple>` is equivalent to using ``Unpack`` to mark the type variable tuple as having been unpacked::
Typing operator to conceptually mark an object as having been unpacked. For example, using the unpack operator ``*`` on a :ref:`type variable tuple <typevartuple>` is equivalent to using ``Unpack`` to mark the type variable tuple as having been unpacked::
python, official-docs, cpython, P0
Local_Trusted_Corpus
c8386569-7db6-4800-8c0a-657984e63afe
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,619
supabase-export-v2
4bbe6163f35ba826
other hand, if an explicit value of ``None`` is allowed, the use of ``Optional`` is appropriate, whether the argument is optional or not. For example:: def foo(arg: Optional[int] = None) -> None: ...
trusted_official_docs
CPython Docs
other hand, if an explicit value of ``None`` is allowed, the use of ``Optional`` is appropriate, whether the argument is optional or not. For example:: def foo(arg: Optional[int] = None) -> None: ...
other hand, if an explicit value of ``None`` is allowed, the use of ``Optional`` is appropriate, whether the argument is optional or not. For example:: def foo(arg: Optional[int] = None) -> None: ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
c8f1e32d-4fa5-45da-bd39-267b45b13e6b
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,064
supabase-export-v2
6fe14ecbf809810e
.. versionadded:: 3.8 .. versionchanged:: 3.12 The internal implementation of :func:`isinstance` checks against runtime-checkable protocols now uses :func:`inspect.getattr_static` to look up attributes (previously, :func:`hasattr` was used). As a result, some objects which used to be considered instances of a runti...
trusted_official_docs
CPython Docs
.. versionadded:: 3.8 .. versionchanged:: 3.12 The internal implementation of :func:`isinstance` checks against runtime-checkable protocols now uses :func:`inspect.getattr_static` to look up attributes (previously, :func:`hasattr` was used). As a result, some objects which used to be considered instances of a runti...
.. versionadded:: 3.8 .. versionchanged:: 3.12 The internal implementation of :func:`isinstance` checks against runtime-checkable protocols now uses :func:`inspect.getattr_static` to look up attributes (previously, :func:`hasattr` was used). As a result, some objects which used to be considered instances of a runti...
python, official-docs, cpython, P0
Local_Trusted_Corpus
c9036a9e-61dd-44f9-939b-aeaf106d80da
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,358
supabase-export-v2
42c6501afa6a3ae7
.. index:: single: ...; ellipsis literal The subscription syntax must always be used with exactly two values: the argument list and the return type. The argument list must be a list of types, a :class:`ParamSpec`, :data:`Concatenate`, or an ellipsis (``...``). The return type must be a single type.
trusted_official_docs
CPython Docs
.. index:: single: ...; ellipsis literal The subscription syntax must always be used with exactly two values: the argument list and the return type. The argument list must be a list of types, a :class:`ParamSpec`, :data:`Concatenate`, or an ellipsis (``...``). The return type must be a single type.
.. index:: single: ...; ellipsis literal The subscription syntax must always be used with exactly two values: the argument list and the return type. The argument list must be a list of types, a :class:`ParamSpec`, :data:`Concatenate`, or an ellipsis (``...``). The return type must be a single type.
python, official-docs, cpython, P0
Local_Trusted_Corpus
c9287050-28e8-4699-9c6c-49597dbaee6a
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,657
supabase-export-v2
b2403fff67fb6479
Special type construct to mark class variables. As introduced in :pep:`526`, a variable annotation wrapped in ClassVar indicates that a given attribute is intended to be used as a class variable and should not be set on instances of that class. Usage::
trusted_official_docs
CPython Docs
Special type construct to mark class variables. As introduced in :pep:`526`, a variable annotation wrapped in ClassVar indicates that a given attribute is intended to be used as a class variable and should not be set on instances of that class. Usage::
Special type construct to mark class variables. As introduced in :pep:`526`, a variable annotation wrapped in ClassVar indicates that a given attribute is intended to be used as a class variable and should not be set on instances of that class. Usage::
python, official-docs, cpython, P0
Local_Trusted_Corpus
c93a8dc2-e747-4c99-acb7-55fcc033c7fd
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,239
supabase-export-v2
f38bbbcf386e2ad3
Decorator to indicate final methods and final classes. Decorating a method with ``@final`` indicates to a type checker that the method cannot be overridden in a subclass. Decorating a class with ``@final`` indicates that it cannot be subclassed.
trusted_official_docs
CPython Docs
Decorator to indicate final methods and final classes. Decorating a method with ``@final`` indicates to a type checker that the method cannot be overridden in a subclass. Decorating a class with ``@final`` indicates that it cannot be subclassed.
Decorator to indicate final methods and final classes. Decorating a method with ``@final`` indicates to a type checker that the method cannot be overridden in a subclass. Decorating a class with ``@final`` indicates that it cannot be subclassed.
python, official-docs, cpython, P0
Local_Trusted_Corpus
c9b86fa7-3ccd-422b-b5e5-e120c56604d3
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,598
supabase-export-v2
f10c25aa554c317c
To define a union, use e.g. ``Union[int, str]`` or the shorthand ``int | str``. Using that shorthand is recommended. Details: * The arguments must be types and there must be at least one.
trusted_official_docs
CPython Docs
To define a union, use e.g. ``Union[int, str]`` or the shorthand ``int | str``. Using that shorthand is recommended. Details: * The arguments must be types and there must be at least one.
To define a union, use e.g. ``Union[int, str]`` or the shorthand ``int | str``. Using that shorthand is recommended. Details: * The arguments must be types and there must be at least one.
python, official-docs, cpython, P0
Local_Trusted_Corpus
ca082a6e-de99-433b-bf70-b59537ab71f7
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,346
supabase-export-v2
7fa7024c7329ccd5
.. versionadded:: 3.5.2 .. versionchanged:: 3.10 ``NewType`` is now a class rather than a function. As a result, there is some additional runtime cost when calling ``NewType`` over a regular function.
trusted_official_docs
CPython Docs
.. versionadded:: 3.5.2 .. versionchanged:: 3.10 ``NewType`` is now a class rather than a function. As a result, there is some additional runtime cost when calling ``NewType`` over a regular function.
.. versionadded:: 3.5.2 .. versionchanged:: 3.10 ``NewType`` is now a class rather than a function. As a result, there is some additional runtime cost when calling ``NewType`` over a regular function.
python, official-docs, cpython, P0
Local_Trusted_Corpus
cb29cbc8-690f-40c5-ac5b-4a4c653cede0
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,399
supabase-export-v2
32caad9cd73fe81e
annotation indicates a tuple of length 1, # but ``z`` has been assigned to a tuple of length 3 z: tuple[int] = (1, 2, 3) .. index:: single: ...; ellipsis literal
trusted_official_docs
CPython Docs
annotation indicates a tuple of length 1, # but ``z`` has been assigned to a tuple of length 3 z: tuple[int] = (1, 2, 3) .. index:: single: ...; ellipsis literal
annotation indicates a tuple of length 1, # but ``z`` has been assigned to a tuple of length 3 z: tuple[int] = (1, 2, 3) .. index:: single: ...; ellipsis literal
python, official-docs, cpython, P0
Local_Trusted_Corpus
cbc397e7-5eda-4c09-8863-f5734013ade6
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,411
supabase-export-v2
b7893c6316837935
Use ``Text`` to indicate that a value must contain a unicode string in a manner that is compatible with both Python 2 and Python 3:: def add_unicode_checkmark(text: Text) -> Text: return text + u' \u2713'
trusted_official_docs
CPython Docs
Use ``Text`` to indicate that a value must contain a unicode string in a manner that is compatible with both Python 2 and Python 3:: def add_unicode_checkmark(text: Text) -> Text: return text + u' \u2713'
Use ``Text`` to indicate that a value must contain a unicode string in a manner that is compatible with both Python 2 and Python 3:: def add_unicode_checkmark(text: Text) -> Text: return text + u' \u2713'
python, official-docs, cpython, P0
Local_Trusted_Corpus
cc1b987d-8ec0-4e65-a513-ee22dd64e1cb
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,819
supabase-export-v2
f24b654837f9272c
# Can be anything with an __abs__ method def print_abs[T: SupportsAbs](arg: T) -> None: print("Absolute value:", abs(arg)) U = TypeVar('U', bound=str|bytes) # Can be any subtype of the union str|bytes V = TypeVar('V', bound=SupportsAbs) # Can be anything with an __abs__ method
trusted_official_docs
CPython Docs
# Can be anything with an __abs__ method def print_abs[T: SupportsAbs](arg: T) -> None: print("Absolute value:", abs(arg)) U = TypeVar('U', bound=str|bytes) # Can be any subtype of the union str|bytes V = TypeVar('V', bound=SupportsAbs) # Can be anything with an __abs__ method
# Can be anything with an __abs__ method def print_abs[T: SupportsAbs](arg: T) -> None: print("Absolute value:", abs(arg)) U = TypeVar('U', bound=str|bytes) # Can be any subtype of the union str|bytes V = TypeVar('V', bound=SupportsAbs) # Can be anything with an __abs__ method
python, official-docs, cpython, P0
Local_Trusted_Corpus
cc2b7bd8-240e-484d-bf5b-93245dcf56b2
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,258
supabase-export-v2
ede18a8a96e098cd
There is no runtime checking of this property. The decorator will attempt to set an ``__override__`` attribute to ``True`` on the decorated object. Thus, a check like ``if getattr(obj, "__override__", False)`` can be used at runtime to determine whether an object ``obj`` has been marked as an override. If the decora...
trusted_official_docs
CPython Docs
There is no runtime checking of this property. The decorator will attempt to set an ``__override__`` attribute to ``True`` on the decorated object. Thus, a check like ``if getattr(obj, "__override__", False)`` can be used at runtime to determine whether an object ``obj`` has been marked as an override. If the decora...
There is no runtime checking of this property. The decorator will attempt to set an ``__override__`` attribute to ``True`` on the decorated object. Thus, a check like ``if getattr(obj, "__override__", False)`` can be used at runtime to determine whether an object ``obj`` has been marked as an override. If the decora...
python, official-docs, cpython, P0
Local_Trusted_Corpus
ccefa014-91c5-4e6d-b23b-bbd42945f62e
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,079
supabase-export-v2
58941ac60a8d9994
# OK, functional syntax Point2D = TypedDict('Point2D', {'in': int, 'x-y': int}) Definition = TypedDict('Definition', {'__schema': str}) # not mangled By default, all keys must be present in a ``TypedDict``. It is possible to mark individual keys as non-required using :data:`NotRequired`::
trusted_official_docs
CPython Docs
# OK, functional syntax Point2D = TypedDict('Point2D', {'in': int, 'x-y': int}) Definition = TypedDict('Definition', {'__schema': str}) # not mangled By default, all keys must be present in a ``TypedDict``. It is possible to mark individual keys as non-required using :data:`NotRequired`::
# OK, functional syntax Point2D = TypedDict('Point2D', {'in': int, 'x-y': int}) Definition = TypedDict('Definition', {'__schema': str}) # not mangled By default, all keys must be present in a ``TypedDict``. It is possible to mark individual keys as non-required using :data:`NotRequired`::
python, official-docs, cpython, P0
Local_Trusted_Corpus
cd790158-a8b8-4385-afb2-af5ec7c7a6cb
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,402
supabase-export-v2
a8a521320b1aa91c
x = (1, 2, 3) x = () # This reassignment is an error: all elements in ``x`` must be ints x = ("foo", "bar") # ``y`` can only ever be assigned to an empty tuple y: tuple[()] = ()
trusted_official_docs
CPython Docs
x = (1, 2, 3) x = () # This reassignment is an error: all elements in ``x`` must be ints x = ("foo", "bar") # ``y`` can only ever be assigned to an empty tuple y: tuple[()] = ()
x = (1, 2, 3) x = () # This reassignment is an error: all elements in ``x`` must be ints x = ("foo", "bar") # ``y`` can only ever be assigned to an empty tuple y: tuple[()] = ()
python, official-docs, cpython, P0
Local_Trusted_Corpus
cdc048c5-da5e-4e34-9e2e-6e75340e31ab
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,224
supabase-export-v2
3f9267d522866443
definition, meanwhile, will be used at runtime but should be ignored by a type checker. At runtime, calling an ``@overload``-decorated function directly will raise :exc:`NotImplementedError`. An example of overload that gives a more precise type than can be expressed using a union or a type variable:
trusted_official_docs
CPython Docs
definition, meanwhile, will be used at runtime but should be ignored by a type checker. At runtime, calling an ``@overload``-decorated function directly will raise :exc:`NotImplementedError`. An example of overload that gives a more precise type than can be expressed using a union or a type variable:
definition, meanwhile, will be used at runtime but should be ignored by a type checker. At runtime, calling an ``@overload``-decorated function directly will raise :exc:`NotImplementedError`. An example of overload that gives a more precise type than can be expressed using a union or a type variable:
python, official-docs, cpython, P0
Local_Trusted_Corpus
cdc9481f-ba98-46d7-bff5-d1932b3f2440
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,635
supabase-export-v2
421a496d607f4578
Special typing form to define "literal types". ``Literal`` can be used to indicate to type checkers that the annotated object has a value equivalent to one of the provided literals.
trusted_official_docs
CPython Docs
Special typing form to define "literal types". ``Literal`` can be used to indicate to type checkers that the annotated object has a value equivalent to one of the provided literals.
Special typing form to define "literal types". ``Literal`` can be used to indicate to type checkers that the annotated object has a value equivalent to one of the provided literals.
python, official-docs, cpython, P0
Local_Trusted_Corpus
ce67314a-4bec-4c04-8234-f4a433dba2a2
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,040
supabase-export-v2
3dcdbfe34f408891
func(C()) # Passes static type check See :pep:`544` for more details. Protocol classes decorated with :func:`runtime_checkable` (described later) act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes without this decorator cannot be ...
trusted_official_docs
CPython Docs
func(C()) # Passes static type check See :pep:`544` for more details. Protocol classes decorated with :func:`runtime_checkable` (described later) act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes without this decorator cannot be ...
func(C()) # Passes static type check See :pep:`544` for more details. Protocol classes decorated with :func:`runtime_checkable` (described later) act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes without this decorator cannot be ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d0386979-1a6c-440f-870e-b3e5bf50b7ef
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,155
supabase-export-v2
a89c5297ea34f09a
represent the types of I/O streams such as returned by :func:`open`. Please note that these classes are not protocols, and their interface is fairly broad. The protocols :class:`io.Reader` and :class:`io.Writer` offer a simpler alternative for argument types, when only the ``read()`` or ``write()`` methods are accessed...
trusted_official_docs
CPython Docs
represent the types of I/O streams such as returned by :func:`open`. Please note that these classes are not protocols, and their interface is fairly broad. The protocols :class:`io.Reader` and :class:`io.Writer` offer a simpler alternative for argument types, when only the ``read()`` or ``write()`` methods are accessed...
represent the types of I/O streams such as returned by :func:`open`. Please note that these classes are not protocols, and their interface is fairly broad. The protocols :class:`io.Reader` and :class:`io.Writer` offer a simpler alternative for argument types, when only the ``read()`` or ``write()`` methods are accessed...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d0cc9129-5add-4b57-ade0-8d20539f2452
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,186
supabase-export-v2
cd3c04f9da06937f
this function prints the runtime type of its argument to :data:`sys.stderr` and returns the argument unchanged (allowing the call to be used within an expression):: x = reveal_type(1) # prints "Runtime type is int" print(x) # prints "1"
trusted_official_docs
CPython Docs
this function prints the runtime type of its argument to :data:`sys.stderr` and returns the argument unchanged (allowing the call to be used within an expression):: x = reveal_type(1) # prints "Runtime type is int" print(x) # prints "1"
this function prints the runtime type of its argument to :data:`sys.stderr` and returns the argument unchanged (allowing the call to be used within an expression):: x = reveal_type(1) # prints "Runtime type is int" print(x) # prints "1"
python, official-docs, cpython, P0
Local_Trusted_Corpus
d1190506-f0e4-4ed4-a4e8-a146702778db
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,308
supabase-export-v2
9cded7669b10f5d8
Type aliases ============ A type alias is defined using the :keyword:`type` statement, which creates an instance of :class:`TypeAliasType`. In this example, ``Vector`` and ``list[float]`` will be treated equivalently by static type checkers::
trusted_official_docs
CPython Docs
Type aliases ============ A type alias is defined using the :keyword:`type` statement, which creates an instance of :class:`TypeAliasType`. In this example, ``Vector`` and ``list[float]`` will be treated equivalently by static type checkers::
Type aliases ============ A type alias is defined using the :keyword:`type` statement, which creates an instance of :class:`TypeAliasType`. In this example, ``Vector`` and ``list[float]`` will be treated equivalently by static type checkers::
python, official-docs, cpython, P0
Local_Trusted_Corpus
d16e2dca-4c73-4e94-a738-944c8d808f0e
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,332
supabase-export-v2
7ef09bf3de69251f
This is similar to calling :meth:`annotationlib.ForwardRef.evaluate`, but unlike that method, :func:`!evaluate_forward_ref` also recursively evaluates forward references nested within the type hint. See the documentation for :meth:`annotationlib.ForwardRef.evaluate` for the meaning of the *owner*, *globals*, *locals*,...
trusted_official_docs
CPython Docs
This is similar to calling :meth:`annotationlib.ForwardRef.evaluate`, but unlike that method, :func:`!evaluate_forward_ref` also recursively evaluates forward references nested within the type hint. See the documentation for :meth:`annotationlib.ForwardRef.evaluate` for the meaning of the *owner*, *globals*, *locals*,...
This is similar to calling :meth:`annotationlib.ForwardRef.evaluate`, but unlike that method, :func:`!evaluate_forward_ref` also recursively evaluates forward references nested within the type hint. See the documentation for :meth:`annotationlib.ForwardRef.evaluate` for the meaning of the *owner*, *globals*, *locals*,...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d4e5a443-f1bb-4228-9423-74267bebf8f4
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,613
supabase-export-v2
f5332a03eb70802e
.. versionchanged:: 3.10 Unions can now be written as ``X | Y``. See :ref:`union type expressions<types-union>`. .. versionchanged:: 3.14 :class:`types.UnionType` is now an alias for :class:`Union`, and both ``Union[int, str]`` and ``int | str`` create instances of the same class. To check whether an object is a ``Un...
trusted_official_docs
CPython Docs
.. versionchanged:: 3.10 Unions can now be written as ``X | Y``. See :ref:`union type expressions<types-union>`. .. versionchanged:: 3.14 :class:`types.UnionType` is now an alias for :class:`Union`, and both ``Union[int, str]`` and ``int | str`` create instances of the same class. To check whether an object is a ``Un...
.. versionchanged:: 3.10 Unions can now be written as ``X | Y``. See :ref:`union type expressions<types-union>`. .. versionchanged:: 3.14 :class:`types.UnionType` is now an alias for :class:`Union`, and both ``Union[int, str]`` and ``int | str`` create instances of the same class. To check whether an object is a ``Un...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d5393a80-d993-4a64-acea-7643a11af19a
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,432
supabase-export-v2
f0577a11d18477e3
async def infinite_stream(start: int) -> AsyncIterator[int]: while True: yield start start = await increment(start) Coroutines can be annotated using :class:`Coroutine[YieldType, SendType, ReturnType] <collections.abc.Coroutine>`. Generic arguments correspond to those of :class:`~collections.abc.Generator`, for example...
trusted_official_docs
CPython Docs
async def infinite_stream(start: int) -> AsyncIterator[int]: while True: yield start start = await increment(start) Coroutines can be annotated using :class:`Coroutine[YieldType, SendType, ReturnType] <collections.abc.Coroutine>`. Generic arguments correspond to those of :class:`~collections.abc.Generator`, for example...
async def infinite_stream(start: int) -> AsyncIterator[int]: while True: yield start start = await increment(start) Coroutines can be annotated using :class:`Coroutine[YieldType, SendType, ReturnType] <collections.abc.Coroutine>`. Generic arguments correspond to those of :class:`~collections.abc.Generator`, for example...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d5706373-2495-434f-b37d-ae4259a58abf
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,508
supabase-export-v2
a00b01619eb98046
def hash_a(item: object) -> int: # Fails type checking; an object does not have a 'magic' method. item.magic() ... def hash_b(item: Any) -> int: # Passes type checking item.magic() ...
trusted_official_docs
CPython Docs
def hash_a(item: object) -> int: # Fails type checking; an object does not have a 'magic' method. item.magic() ... def hash_b(item: Any) -> int: # Passes type checking item.magic() ...
def hash_a(item: object) -> int: # Fails type checking; an object does not have a 'magic' method. item.magic() ... def hash_b(item: Any) -> int: # Passes type checking item.magic() ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d5a0b3d3-134f-49e2-81e3-e04e2b470227
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,528
supabase-export-v2
2c81588b64f4dcdc
.. list-table:: :header-rows: 1 * - Feature - Deprecated in - Projected removal - PEP/issue * - ``typing`` versions of standard collections - 3.9 - Undecided (see :ref:`deprecated-aliases` for more information) - :pep:`585` * - :class:`typing.ByteString` - 3.9 - 3.17 - :gh:`91896` * - :data:`typing.Text` -...
trusted_official_docs
CPython Docs
.. list-table:: :header-rows: 1 * - Feature - Deprecated in - Projected removal - PEP/issue * - ``typing`` versions of standard collections - 3.9 - Undecided (see :ref:`deprecated-aliases` for more information) - :pep:`585` * - :class:`typing.ByteString` - 3.9 - 3.17 - :gh:`91896` * - :data:`typing.Text` -...
.. list-table:: :header-rows: 1 * - Feature - Deprecated in - Projected removal - PEP/issue * - ``typing`` versions of standard collections - 3.9 - Undecided (see :ref:`deprecated-aliases` for more information) - :pep:`585` * - :class:`typing.ByteString` - 3.9 - 3.17 - :gh:`91896` * - :data:`typing.Text` -...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d603ad7b-16e5-4488-a883-d3cbb18afd06
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,499
supabase-export-v2
5d58d54059dc4ee8
s: str = '' s = a # OK def foo(item: Any) -> int: # Passes type checking; 'item' could be any type, # and that type might have a 'bar' method item.bar() ...
trusted_official_docs
CPython Docs
s: str = '' s = a # OK def foo(item: Any) -> int: # Passes type checking; 'item' could be any type, # and that type might have a 'bar' method item.bar() ...
s: str = '' s = a # OK def foo(item: Any) -> int: # Passes type checking; 'item' could be any type, # and that type might have a 'bar' method item.bar() ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d7bd3519-2a35-4c50-a81d-e39c52b8a00d
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,275
supabase-export-v2
b7014203eb90027b
runtime. It is mainly intended to mark classes that are defined in type stub files if an implementation returns an instance of a private class:: @type_check_only class Response: # private or not available at runtime code: int def get_header(self, name: str) -> str: ...
trusted_official_docs
CPython Docs
runtime. It is mainly intended to mark classes that are defined in type stub files if an implementation returns an instance of a private class:: @type_check_only class Response: # private or not available at runtime code: int def get_header(self, name: str) -> str: ...
runtime. It is mainly intended to mark classes that are defined in type stub files if an implementation returns an instance of a private class:: @type_check_only class Response: # private or not available at runtime code: int def get_header(self, name: str) -> str: ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d8e94534-2541-4071-a21a-b6fcf33fea7f
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,906
supabase-export-v2
5064d5d69748d83b
.. versionadded:: 3.13 Type variable tuples created with ``covariant=True`` or ``contravariant=True`` can be used to declare covariant or contravariant generic types. The ``bound`` argument is also accepted, similar to :class:`TypeVar`, but its actual semantics are yet to be decided.
trusted_official_docs
CPython Docs
.. versionadded:: 3.13 Type variable tuples created with ``covariant=True`` or ``contravariant=True`` can be used to declare covariant or contravariant generic types. The ``bound`` argument is also accepted, similar to :class:`TypeVar`, but its actual semantics are yet to be decided.
.. versionadded:: 3.13 Type variable tuples created with ``covariant=True`` or ``contravariant=True`` can be used to declare covariant or contravariant generic types. The ``bound`` argument is also accepted, similar to :class:`TypeVar`, but its actual semantics are yet to be decided.
python, official-docs, cpython, P0
Local_Trusted_Corpus
d8ff72d2-4c28-4366-b421-dbdb78dbe4e4
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,927
supabase-export-v2
e5a2bf39f6b54378
.. attribute:: args .. attribute:: kwargs Since ``ParamSpec`` captures both positional and keyword parameters, ``P.args`` and ``P.kwargs`` can be used to split a ``ParamSpec`` into its components. ``P.args`` represents the tuple of positional parameters in a given call and should only be used to annotate ``*args``. ...
trusted_official_docs
CPython Docs
.. attribute:: args .. attribute:: kwargs Since ``ParamSpec`` captures both positional and keyword parameters, ``P.args`` and ``P.kwargs`` can be used to split a ``ParamSpec`` into its components. ``P.args`` represents the tuple of positional parameters in a given call and should only be used to annotate ``*args``. ...
.. attribute:: args .. attribute:: kwargs Since ``ParamSpec`` captures both positional and keyword parameters, ``P.args`` and ``P.kwargs`` can be used to split a ``ParamSpec`` into its components. ``P.args`` represents the tuple of positional parameters in a given call and should only be used to annotate ``*args``. ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d910ba47-4b8c-4130-9c9b-720117ef8f42
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,501
supabase-export-v2
6836ce4f9424be5b
report an error when assigning ``a`` to ``s`` even though ``s`` was declared to be of type :class:`str` and receives an :class:`int` value at runtime! Furthermore, all functions without a return type or parameter types will implicitly default to using :data:`Any`::
trusted_official_docs
CPython Docs
report an error when assigning ``a`` to ``s`` even though ``s`` was declared to be of type :class:`str` and receives an :class:`int` value at runtime! Furthermore, all functions without a return type or parameter types will implicitly default to using :data:`Any`::
report an error when assigning ``a`` to ``s`` even though ``s`` was declared to be of type :class:`str` and receives an :class:`int` value at runtime! Furthermore, all functions without a return type or parameter types will implicitly default to using :data:`Any`::
python, official-docs, cpython, P0
Local_Trusted_Corpus
d93f24da-0547-4967-9838-df5d4c90156e
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,415
supabase-export-v2
7a78d406b1d229db
new_non_team_user(BasicUser) # OK new_non_team_user(ProUser) # OK new_non_team_user(TeamUser) # Error: ``type[TeamUser]`` is not a subtype # of ``type[BasicUser | ProUser]`` new_non_team_user(User) # Also an error ``type[Any]`` is equivalent to :class:`type`, which is the root of Python's :ref:`metaclass hierarchy <met...
trusted_official_docs
CPython Docs
new_non_team_user(BasicUser) # OK new_non_team_user(ProUser) # OK new_non_team_user(TeamUser) # Error: ``type[TeamUser]`` is not a subtype # of ``type[BasicUser | ProUser]`` new_non_team_user(User) # Also an error ``type[Any]`` is equivalent to :class:`type`, which is the root of Python's :ref:`metaclass hierarchy <met...
new_non_team_user(BasicUser) # OK new_non_team_user(ProUser) # OK new_non_team_user(TeamUser) # Error: ``type[TeamUser]`` is not a subtype # of ``type[BasicUser | ProUser]`` new_non_team_user(User) # Also an error ``type[Any]`` is equivalent to :class:`type`, which is the root of Python's :ref:`metaclass hierarchy <met...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d9b25ea5-0287-4df1-a4db-463ddac7e1c3
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,803
supabase-export-v2
6be8366d84db45c1
class StrSequence[S: str]: # S is a TypeVar with a `str` upper bound; ... # we can say that S is "bounded by `str`" class StrOrBytesSequence[A: (str, bytes)]: # A is a TypeVar constrained to str or bytes ...
trusted_official_docs
CPython Docs
class StrSequence[S: str]: # S is a TypeVar with a `str` upper bound; ... # we can say that S is "bounded by `str`" class StrOrBytesSequence[A: (str, bytes)]: # A is a TypeVar constrained to str or bytes ...
class StrSequence[S: str]: # S is a TypeVar with a `str` upper bound; ... # we can say that S is "bounded by `str`" class StrOrBytesSequence[A: (str, bytes)]: # A is a TypeVar constrained to str or bytes ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
da0eba31-fae2-470a-97dc-79c86ef8d03a
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,041
supabase-export-v2
081e5eac28debee0
the presence of given attributes, ignoring their type signatures. Protocol classes without this decorator cannot be used as the second argument to :func:`isinstance` or :func:`issubclass`. Protocol classes can be generic, for example::
trusted_official_docs
CPython Docs
the presence of given attributes, ignoring their type signatures. Protocol classes without this decorator cannot be used as the second argument to :func:`isinstance` or :func:`issubclass`. Protocol classes can be generic, for example::
the presence of given attributes, ignoring their type signatures. Protocol classes without this decorator cannot be used as the second argument to :func:`isinstance` or :func:`issubclass`. Protocol classes can be generic, for example::
python, official-docs, cpython, P0
Local_Trusted_Corpus
da103a6c-fe95-4980-ac4b-50736ab714f1
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,561
supabase-export-v2
bf07a76e95004cb0
def never_call_me(arg: Never) -> None: pass def int_or_str(arg: int | str) -> None: never_call_me(arg) # type checker error match arg: case int(): print("It's an int") case str(): print("It's a str") case _: never_call_me(arg) # OK, arg is of type Never (or NoReturn)
trusted_official_docs
CPython Docs
def never_call_me(arg: Never) -> None: pass def int_or_str(arg: int | str) -> None: never_call_me(arg) # type checker error match arg: case int(): print("It's an int") case str(): print("It's a str") case _: never_call_me(arg) # OK, arg is of type Never (or NoReturn)
def never_call_me(arg: Never) -> None: pass def int_or_str(arg: int | str) -> None: never_call_me(arg) # type checker error match arg: case int(): print("It's an int") case str(): print("It's a str") case _: never_call_me(arg) # OK, arg is of type Never (or NoReturn)
python, official-docs, cpython, P0
Local_Trusted_Corpus
dae10f94-726c-4ff9-8b0a-d71f27b3d862
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,317
supabase-export-v2
ed2321d5b34f7bf3
the previous type signature as # being exactly equivalent to this one. def broadcast_message( message: str, servers: Sequence[tuple[tuple[str, int], dict[str, str]]] ) -> None: ... The :keyword:`type` statement is new in Python 3.12. For backwards compatibility, type aliases can also be created through simple assignmen...
trusted_official_docs
CPython Docs
the previous type signature as # being exactly equivalent to this one. def broadcast_message( message: str, servers: Sequence[tuple[tuple[str, int], dict[str, str]]] ) -> None: ... The :keyword:`type` statement is new in Python 3.12. For backwards compatibility, type aliases can also be created through simple assignmen...
the previous type signature as # being exactly equivalent to this one. def broadcast_message( message: str, servers: Sequence[tuple[tuple[str, int], dict[str, str]]] ) -> None: ... The :keyword:`type` statement is new in Python 3.12. For backwards compatibility, type aliases can also be created through simple assignmen...
python, official-docs, cpython, P0
Local_Trusted_Corpus
db20a2c0-93ea-4975-b580-37c7bb43d863
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,316
supabase-export-v2
5eeed74a3a00a96c
def broadcast_message(message: str, servers: Sequence[Server]) -> None: ... # The static type checker will treat the previous type signature as # being exactly equivalent to this one. def broadcast_message( message: str, servers: Sequence[tuple[tuple[str, int], dict[str, str]]] ) -> None: ...
trusted_official_docs
CPython Docs
def broadcast_message(message: str, servers: Sequence[Server]) -> None: ... # The static type checker will treat the previous type signature as # being exactly equivalent to this one. def broadcast_message( message: str, servers: Sequence[tuple[tuple[str, int], dict[str, str]]] ) -> None: ...
def broadcast_message(message: str, servers: Sequence[Server]) -> None: ... # The static type checker will treat the previous type signature as # being exactly equivalent to this one. def broadcast_message( message: str, servers: Sequence[tuple[tuple[str, int], dict[str, str]]] ) -> None: ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
dbbd3b07-5c2b-47aa-a471-c4ad431c518d
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,521
supabase-export-v2
485e4302d069d4ce
Deprecated alias to :class:`contextlib.AbstractAsyncContextManager`. The first type parameter, ``T_co``, represents the type returned by the :meth:`~object.__aenter__` method. The optional second type parameter, ``AExitT_co``, which defaults to ``bool | None``, represents the type returned by the :meth:`~object.__ae...
trusted_official_docs
CPython Docs
Deprecated alias to :class:`contextlib.AbstractAsyncContextManager`. The first type parameter, ``T_co``, represents the type returned by the :meth:`~object.__aenter__` method. The optional second type parameter, ``AExitT_co``, which defaults to ``bool | None``, represents the type returned by the :meth:`~object.__ae...
Deprecated alias to :class:`contextlib.AbstractAsyncContextManager`. The first type parameter, ``T_co``, represents the type returned by the :meth:`~object.__aenter__` method. The optional second type parameter, ``AExitT_co``, which defaults to ``bool | None``, represents the type returned by the :meth:`~object.__ae...
python, official-docs, cpython, P0
Local_Trusted_Corpus
dc226e7a-efea-419a-bb45-976c0a5af3ac
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,716
supabase-export-v2
16cc74f95cf97216
type Variadic[*Ts] = Annotated[*Ts, Ann1] = Annotated[T1, T2, T3, ..., Ann1] # NOT valid where ``T1``, ``T2``, ... are :class:`TypeVars <TypeVar>`. This is invalid as only one type should be passed to Annotated.
trusted_official_docs
CPython Docs
type Variadic[*Ts] = Annotated[*Ts, Ann1] = Annotated[T1, T2, T3, ..., Ann1] # NOT valid where ``T1``, ``T2``, ... are :class:`TypeVars <TypeVar>`. This is invalid as only one type should be passed to Annotated.
type Variadic[*Ts] = Annotated[*Ts, Ann1] = Annotated[T1, T2, T3, ..., Ann1] # NOT valid where ``T1``, ``T2``, ... are :class:`TypeVars <TypeVar>`. This is invalid as only one type should be passed to Annotated.
python, official-docs, cpython, P0
Local_Trusted_Corpus
dc60348f-9464-41ac-8f09-0077a741eb85
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,922
supabase-export-v2
c19896e418018e7a
from collections.abc import Callable import logging def add_logging[T, **P](f: Callable[P, T]) -> Callable[P, T]: '''A type-safe decorator to add logging to a function.''' def inner(*args: P.args, **kwargs: P.kwargs) -> T: logging.info(f'{f.__name__} was called') return f(*args, **kwargs) return inner
trusted_official_docs
CPython Docs
from collections.abc import Callable import logging def add_logging[T, **P](f: Callable[P, T]) -> Callable[P, T]: '''A type-safe decorator to add logging to a function.''' def inner(*args: P.args, **kwargs: P.kwargs) -> T: logging.info(f'{f.__name__} was called') return f(*args, **kwargs) return inner
from collections.abc import Callable import logging def add_logging[T, **P](f: Callable[P, T]) -> Callable[P, T]: '''A type-safe decorator to add logging to a function.''' def inner(*args: P.args, **kwargs: P.kwargs) -> T: logging.info(f'{f.__name__} was called') return f(*args, **kwargs) return inner
python, official-docs, cpython, P0
Local_Trusted_Corpus
dd151692-349a-43b9-9778-8ecc7926869c
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,204
supabase-export-v2
178e762a366724af
class CustomerModel(ModelBase): id: int name: str The ``CustomerModel`` classes defined above will be treated by type checkers similarly to classes created with :deco:`dataclasses.dataclass`. For example, type checkers will assume these classes have ``__init__`` methods that accept ``id`` and ``name``.
trusted_official_docs
CPython Docs
class CustomerModel(ModelBase): id: int name: str The ``CustomerModel`` classes defined above will be treated by type checkers similarly to classes created with :deco:`dataclasses.dataclass`. For example, type checkers will assume these classes have ``__init__`` methods that accept ``id`` and ``name``.
class CustomerModel(ModelBase): id: int name: str The ``CustomerModel`` classes defined above will be treated by type checkers similarly to classes created with :deco:`dataclasses.dataclass`. For example, type checkers will assume these classes have ``__init__`` methods that accept ``id`` and ``name``.
python, official-docs, cpython, P0
Local_Trusted_Corpus
dd2c9489-7996-4382-8617-bb6cbf51249b
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,477
supabase-export-v2
55cbee54769057cc
def inproduct[T: (int, float, complex)](v: Vec[T]) -> T: # Same as Iterable[tuple[T, T]] return sum(x*y for x, y in v) For backward compatibility, generic type aliases can also be created through a simple assignment::
trusted_official_docs
CPython Docs
def inproduct[T: (int, float, complex)](v: Vec[T]) -> T: # Same as Iterable[tuple[T, T]] return sum(x*y for x, y in v) For backward compatibility, generic type aliases can also be created through a simple assignment::
def inproduct[T: (int, float, complex)](v: Vec[T]) -> T: # Same as Iterable[tuple[T, T]] return sum(x*y for x, y in v) For backward compatibility, generic type aliases can also be created through a simple assignment::
python, official-docs, cpython, P0
Local_Trusted_Corpus
dda8846e-ccf6-4518-8036-e065d9e11aa2
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,538
supabase-export-v2
e3493f22bafacc0d
def concat(a: AnyStr, b: AnyStr) -> AnyStr: return a + b concat("foo", "bar") # OK, output has type 'str' concat(b"foo", b"bar") # OK, output has type 'bytes' concat("foo", b"bar") # Error, cannot mix str and bytes
trusted_official_docs
CPython Docs
def concat(a: AnyStr, b: AnyStr) -> AnyStr: return a + b concat("foo", "bar") # OK, output has type 'str' concat(b"foo", b"bar") # OK, output has type 'bytes' concat("foo", b"bar") # Error, cannot mix str and bytes
def concat(a: AnyStr, b: AnyStr) -> AnyStr: return a + b concat("foo", "bar") # OK, output has type 'str' concat(b"foo", b"bar") # OK, output has type 'bytes' concat("foo", b"bar") # Error, cannot mix str and bytes
python, official-docs, cpython, P0
Local_Trusted_Corpus
ddabce96-3700-4614-9d5f-6d3de7ef1729
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,120
supabase-export-v2
3489b35aaaf10164
.. note:: If ``from __future__ import annotations`` is used or if annotations are given as strings, annotations are not evaluated when the ``TypedDict`` is defined. Therefore, the runtime introspection that ``__required_keys__`` and ``__optional_keys__`` rely on may not work properly, and the values of the attribut...
trusted_official_docs
CPython Docs
.. note:: If ``from __future__ import annotations`` is used or if annotations are given as strings, annotations are not evaluated when the ``TypedDict`` is defined. Therefore, the runtime introspection that ``__required_keys__`` and ``__optional_keys__`` rely on may not work properly, and the values of the attribut...
.. note:: If ``from __future__ import annotations`` is used or if annotations are given as strings, annotations are not evaluated when the ``TypedDict`` is defined. Therefore, the runtime introspection that ``__required_keys__`` and ``__optional_keys__`` rely on may not work properly, and the values of the attribut...
python, official-docs, cpython, P0
Local_Trusted_Corpus
ddc64f26-0fd2-4abd-b001-be5ba9932efd
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,218
supabase-export-v2
7cfb406e8c78da2c
``dataclass_transform`` will be used. * - ``alias`` - Provides an alternative name for the field. This alternative name is used in the synthesized ``__init__`` method. At runtime, this decorator records its arguments in the ``__dataclass_transform__`` attribute on the decorated object. It has no other runtime effect.
trusted_official_docs
CPython Docs
``dataclass_transform`` will be used. * - ``alias`` - Provides an alternative name for the field. This alternative name is used in the synthesized ``__init__`` method. At runtime, this decorator records its arguments in the ``__dataclass_transform__`` attribute on the decorated object. It has no other runtime effect.
``dataclass_transform`` will be used. * - ``alias`` - Provides an alternative name for the field. This alternative name is used in the synthesized ``__init__`` method. At runtime, this decorator records its arguments in the ``__dataclass_transform__`` attribute on the decorated object. It has no other runtime effect.
python, official-docs, cpython, P0
Local_Trusted_Corpus
df318760-2371-4ca2-becc-6092342531b6
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,167
supabase-export-v2
bbbea33d306079dd
When a static type checker encounters a call to ``assert_type()``, it emits an error if the value is not of the specified type:: def greet(name: str) -> None: assert_type(name, str) # OK, inferred type of `name` is `str` assert_type(name, int) # type checker error
trusted_official_docs
CPython Docs
When a static type checker encounters a call to ``assert_type()``, it emits an error if the value is not of the specified type:: def greet(name: str) -> None: assert_type(name, str) # OK, inferred type of `name` is `str` assert_type(name, int) # type checker error
When a static type checker encounters a call to ``assert_type()``, it emits an error if the value is not of the specified type:: def greet(name: str) -> None: assert_type(name, str) # OK, inferred type of `name` is `str` assert_type(name, int) # type checker error
python, official-docs, cpython, P0
Local_Trusted_Corpus
dfde6cdd-9472-41d8-a62a-bd141c4666e4
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,753
supabase-export-v2
c1d98583cdd47a7e
is equivalent to # ``Child``. assert_type(arg, Child) else: # Type of ``arg`` is narrowed to exclude ``Parent``, # so only ``Unrelated`` is left. assert_type(arg, Unrelated) The type inside ``TypeIs`` must be consistent with the type of the function's argument; if it is not, static type checkers will raise an error. ...
trusted_official_docs
CPython Docs
is equivalent to # ``Child``. assert_type(arg, Child) else: # Type of ``arg`` is narrowed to exclude ``Parent``, # so only ``Unrelated`` is left. assert_type(arg, Unrelated) The type inside ``TypeIs`` must be consistent with the type of the function's argument; if it is not, static type checkers will raise an error. ...
is equivalent to # ``Child``. assert_type(arg, Child) else: # Type of ``arg`` is narrowed to exclude ``Parent``, # so only ``Unrelated`` is left. assert_type(arg, Unrelated) The type inside ``TypeIs`` must be consistent with the type of the function's argument; if it is not, static type checkers will raise an error. ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e01c6f9d-0a27-4f6d-b579-732227975ec4
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,810
supabase-export-v2
adfe280b78362bc1
def concatenate[A: (str, bytes)](x: A, y: A) -> A: """Add two strings or bytes objects together.""" return x + y Note that type variables can be *bounded*, *constrained*, or neither, but cannot be both bounded *and* constrained.
trusted_official_docs
CPython Docs
def concatenate[A: (str, bytes)](x: A, y: A) -> A: """Add two strings or bytes objects together.""" return x + y Note that type variables can be *bounded*, *constrained*, or neither, but cannot be both bounded *and* constrained.
def concatenate[A: (str, bytes)](x: A, y: A) -> A: """Add two strings or bytes objects together.""" return x + y Note that type variables can be *bounded*, *constrained*, or neither, but cannot be both bounded *and* constrained.
python, official-docs, cpython, P0
Local_Trusted_Corpus
e0ee2d5c-029c-4f65-9348-8ff3b2ad327b
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,920
supabase-export-v2
b10c77f0607ad2c5
when used in ``Concatenate``, or as the first argument to ``Callable``, or as parameters for user-defined Generics. See :class:`Generic` for more information on generic types. For example, to add basic logging to a function, one can create a decorator ``add_logging`` to log function calls. The parameter specification ...
trusted_official_docs
CPython Docs
when used in ``Concatenate``, or as the first argument to ``Callable``, or as parameters for user-defined Generics. See :class:`Generic` for more information on generic types. For example, to add basic logging to a function, one can create a decorator ``add_logging`` to log function calls. The parameter specification ...
when used in ``Concatenate``, or as the first argument to ``Callable``, or as parameters for user-defined Generics. See :class:`Generic` for more information on generic types. For example, to add basic logging to a function, one can create a decorator ``add_logging`` to log function calls. The parameter specification ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e14772c7-ab39-4aae-8979-167d4aa096ca
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,562
supabase-export-v2
36c333343c1969f6
error match arg: case int(): print("It's an int") case str(): print("It's a str") case _: never_call_me(arg) # OK, arg is of type Never (or NoReturn) :data:`!Never` and :data:`!NoReturn` have the same meaning in the type system and static type checkers treat both equivalently.
trusted_official_docs
CPython Docs
error match arg: case int(): print("It's an int") case str(): print("It's a str") case _: never_call_me(arg) # OK, arg is of type Never (or NoReturn) :data:`!Never` and :data:`!NoReturn` have the same meaning in the type system and static type checkers treat both equivalently.
error match arg: case int(): print("It's an int") case str(): print("It's a str") case _: never_call_me(arg) # OK, arg is of type Never (or NoReturn) :data:`!Never` and :data:`!NoReturn` have the same meaning in the type system and static type checkers treat both equivalently.
python, official-docs, cpython, P0
Local_Trusted_Corpus
e168c68e-5d34-4d9a-a499-fea9393ac826
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,406
supabase-export-v2
e1959032d5205bdd
The type of class objects ========================= A variable annotated with ``C`` may accept a value of type ``C``. In contrast, a variable annotated with ``type[C]`` (or deprecated :class:`typing.Type[C] <Type>`) may accept values that are classes themselves -- specifically, it will accept the *class object* of ``C`...
trusted_official_docs
CPython Docs
The type of class objects ========================= A variable annotated with ``C`` may accept a value of type ``C``. In contrast, a variable annotated with ``type[C]`` (or deprecated :class:`typing.Type[C] <Type>`) may accept values that are classes themselves -- specifically, it will accept the *class object* of ``C`...
The type of class objects ========================= A variable annotated with ``C`` may accept a value of type ``C``. In contrast, a variable annotated with ``type[C]`` (or deprecated :class:`typing.Type[C] <Type>`) may accept values that are classes themselves -- specifically, it will accept the *class object* of ``C`...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e26c57f6-6991-46af-8476-e08a3fbe6e7f
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,131
supabase-export-v2
dbd12e1b9579337e
.. versionchanged:: 3.9 ``TypedDict`` is now a function rather than a class. It can still be used as a class base, as described above. .. versionchanged:: 3.11 Added support for marking individual keys as :data:`Required` or :data:`NotRequired`. See :pep:`655`.
trusted_official_docs
CPython Docs
.. versionchanged:: 3.9 ``TypedDict`` is now a function rather than a class. It can still be used as a class base, as described above. .. versionchanged:: 3.11 Added support for marking individual keys as :data:`Required` or :data:`NotRequired`. See :pep:`655`.
.. versionchanged:: 3.9 ``TypedDict`` is now a function rather than a class. It can still be used as a class base, as described above. .. versionchanged:: 3.11 Added support for marking individual keys as :data:`Required` or :data:`NotRequired`. See :pep:`655`.
python, official-docs, cpython, P0
Local_Trusted_Corpus
e3192763-0a2e-4bdd-a877-983d44ff3cca
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,589
supabase-export-v2
9b19dcc1737ab3a3
Using ``TypeAlias`` tells the type checker that this is a type alias declaration, # not a variable assignment to a string. BoxOfStrings: TypeAlias = "Box[str]" class Box(Generic[T]): @classmethod def make_box_of_strings(cls) -> BoxOfStrings: ...
trusted_official_docs
CPython Docs
Using ``TypeAlias`` tells the type checker that this is a type alias declaration, # not a variable assignment to a string. BoxOfStrings: TypeAlias = "Box[str]" class Box(Generic[T]): @classmethod def make_box_of_strings(cls) -> BoxOfStrings: ...
Using ``TypeAlias`` tells the type checker that this is a type alias declaration, # not a variable assignment to a string. BoxOfStrings: TypeAlias = "Box[str]" class Box(Generic[T]): @classmethod def make_box_of_strings(cls) -> BoxOfStrings: ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e4cad755-1af5-4b48-9649-9a70fff6e8fe
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,406
supabase-export-v2
18f8b71b7c9114f1
types (and the corresponding functions) are generic over :data:`AnyStr`. ``Pattern`` can be specialised as ``Pattern[str]`` or ``Pattern[bytes]``; ``Match`` can be specialised as ``Match[str]`` or ``Match[bytes]``. .. deprecated:: 3.9 Classes ``Pattern`` and ``Match`` from :mod:`re` now support ``[]``. See :pep:`585` ...
trusted_official_docs
CPython Docs
types (and the corresponding functions) are generic over :data:`AnyStr`. ``Pattern`` can be specialised as ``Pattern[str]`` or ``Pattern[bytes]``; ``Match`` can be specialised as ``Match[str]`` or ``Match[bytes]``. .. deprecated:: 3.9 Classes ``Pattern`` and ``Match`` from :mod:`re` now support ``[]``. See :pep:`585` ...
types (and the corresponding functions) are generic over :data:`AnyStr`. ``Pattern`` can be specialised as ``Pattern[str]`` or ``Pattern[bytes]``; ``Match`` can be specialised as ``Match[str]`` or ``Match[bytes]``. .. deprecated:: 3.9 Classes ``Pattern`` and ``Match`` from :mod:`re` now support ``[]``. See :pep:`585` ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e714cbbe-5066-4534-b637-e8f92ca2a85d
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,692
supabase-export-v2
104a7f02403abda2
decorator, which can also be used for adding annotations outside the scope of the typing system, but completely disables typechecking for a function or class. The responsibility of how to interpret the metadata lies with the tool or library encountering an ``Annotated`` annotation. A tool or library encountering an `...
trusted_official_docs
CPython Docs
decorator, which can also be used for adding annotations outside the scope of the typing system, but completely disables typechecking for a function or class. The responsibility of how to interpret the metadata lies with the tool or library encountering an ``Annotated`` annotation. A tool or library encountering an `...
decorator, which can also be used for adding annotations outside the scope of the typing system, but completely disables typechecking for a function or class. The responsibility of how to interpret the metadata lies with the tool or library encountering an ``Annotated`` annotation. A tool or library encountering an `...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e86af651-8e62-4b97-a5cb-3974b8bbb6c0
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,296
supabase-export-v2
e5f6aa96e12b3146
Get the unsubscripted version of a type: for a typing object of the form ``X[Y, Z, ...]`` return ``X``. If ``X`` is a typing-module alias for a builtin or :mod:`collections` class, it will be normalized to the original class. If ``X`` is an instance of :class:`ParamSpecArgs` or :class:`ParamSpecKwargs`, return the un...
trusted_official_docs
CPython Docs
Get the unsubscripted version of a type: for a typing object of the form ``X[Y, Z, ...]`` return ``X``. If ``X`` is a typing-module alias for a builtin or :mod:`collections` class, it will be normalized to the original class. If ``X`` is an instance of :class:`ParamSpecArgs` or :class:`ParamSpecKwargs`, return the un...
Get the unsubscripted version of a type: for a typing object of the form ``X[Y, Z, ...]`` return ``X``. If ``X`` is a typing-module alias for a builtin or :mod:`collections` class, it will be normalized to the original class. If ``X`` is an instance of :class:`ParamSpecArgs` or :class:`ParamSpecKwargs`, return the un...
python, official-docs, cpython, P0
Local_Trusted_Corpus
ecd0e016-2a5a-4891-9148-3d579c9844ce
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,846
supabase-export-v2
deb92f952d556448
.. method:: evaluate_constraints An :term:`evaluate function` corresponding to the :attr:`~TypeVar.__constraints__` attribute. When called directly, this method supports only the :attr:`~annotationlib.Format.VALUE` format, which is equivalent to accessing the :attr:`~TypeVar.__constraints__` attribute directly, but t...
trusted_official_docs
CPython Docs
.. method:: evaluate_constraints An :term:`evaluate function` corresponding to the :attr:`~TypeVar.__constraints__` attribute. When called directly, this method supports only the :attr:`~annotationlib.Format.VALUE` format, which is equivalent to accessing the :attr:`~TypeVar.__constraints__` attribute directly, but t...
.. method:: evaluate_constraints An :term:`evaluate function` corresponding to the :attr:`~TypeVar.__constraints__` attribute. When called directly, this method supports only the :attr:`~annotationlib.Format.VALUE` format, which is equivalent to accessing the :attr:`~TypeVar.__constraints__` attribute directly, but t...
python, official-docs, cpython, P0
Local_Trusted_Corpus
ed7ffc8d-36ff-450d-8677-d347603e21bd
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,326
supabase-export-v2
62fc3e266b03575b
type checker will treat the new type as if it were a subclass of the original type. This is useful in helping catch logical errors:: def get_user_name(user_id: UserId) -> str: ...
trusted_official_docs
CPython Docs
type checker will treat the new type as if it were a subclass of the original type. This is useful in helping catch logical errors:: def get_user_name(user_id: UserId) -> str: ...
type checker will treat the new type as if it were a subclass of the original type. This is useful in helping catch logical errors:: def get_user_name(user_id: UserId) -> str: ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
ee4bcde0-d6eb-4fc9-8fb4-e53a37168095
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,330
supabase-export-v2
186f58edbd2e308e
lets you pass in a ``UserId`` wherever an ``int`` might be expected, but will prevent you from accidentally creating a ``UserId`` in an invalid way:: # 'output' is of type 'int', not 'UserId' output = UserId(23413) + UserId(54341)
trusted_official_docs
CPython Docs
lets you pass in a ``UserId`` wherever an ``int`` might be expected, but will prevent you from accidentally creating a ``UserId`` in an invalid way:: # 'output' is of type 'int', not 'UserId' output = UserId(23413) + UserId(54341)
lets you pass in a ``UserId`` wherever an ``int`` might be expected, but will prevent you from accidentally creating a ``UserId`` in an invalid way:: # 'output' is of type 'int', not 'UserId' output = UserId(23413) + UserId(54341)
python, official-docs, cpython, P0
Local_Trusted_Corpus
ef8dfa4a-5301-4584-a80f-119d6548f416
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,490
supabase-export-v2
c678621ec75eb1e7
>>> class X[**P]: ... ... >>> X[int, str] __main__.X[[int, str]] >>> X[[int, str]] __main__.X[[int, str]] Note that generics with :class:`ParamSpec` may not have correct ``__parameters__`` after substitution in some cases because they are intended primarily for static type checking.
trusted_official_docs
CPython Docs
>>> class X[**P]: ... ... >>> X[int, str] __main__.X[[int, str]] >>> X[[int, str]] __main__.X[[int, str]] Note that generics with :class:`ParamSpec` may not have correct ``__parameters__`` after substitution in some cases because they are intended primarily for static type checking.
>>> class X[**P]: ... ... >>> X[int, str] __main__.X[[int, str]] >>> X[[int, str]] __main__.X[[int, str]] Note that generics with :class:`ParamSpec` may not have correct ``__parameters__`` after substitution in some cases because they are intended primarily for static type checking.
python, official-docs, cpython, P0
Local_Trusted_Corpus