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
660cf70e-73c7-49e3-99ac-35d7cabfb8b2
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,467
supabase-export-v2
68b906c1ae4b2453
In this case ``MyDict`` has a single parameter, ``T``. Using a generic class without specifying type parameters assumes :data:`Any` for each position. In the following example, ``MyIterable`` is not generic but implicitly inherits from ``Iterable[Any]``:
trusted_official_docs
CPython Docs
In this case ``MyDict`` has a single parameter, ``T``. Using a generic class without specifying type parameters assumes :data:`Any` for each position. In the following example, ``MyIterable`` is not generic but implicitly inherits from ``Iterable[Any]``:
In this case ``MyDict`` has a single parameter, ``T``. Using a generic class without specifying type parameters assumes :data:`Any` for each position. In the following example, ``MyIterable`` is not generic but implicitly inherits from ``Iterable[Any]``:
python, official-docs, cpython, P0
Local_Trusted_Corpus
66cf1a8b-e60e-4120-91f9-107809cca29f
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,513
supabase-export-v2
f0250a4100ea1012
Nominal vs structural subtyping =============================== Initially :pep:`484` defined the Python static type system as using *nominal 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``.
trusted_official_docs
CPython Docs
Nominal vs structural subtyping =============================== Initially :pep:`484` defined the Python static type system as using *nominal 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``.
Nominal vs structural subtyping =============================== Initially :pep:`484` defined the Python static type system as using *nominal 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``.
python, official-docs, cpython, P0
Local_Trusted_Corpus
66d4936e-f761-46cc-857c-71d52342cc39
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,588
supabase-export-v2
aeab42ae86dc388c
T = TypeVar("T") # "Box" does not exist yet, # so we have to use quotes for the forward reference on Python <3.12. # Using ``TypeAlias`` tells the type checker that this is a type alias declaration, # not a variable assignment to a string. BoxOfStrings: TypeAlias = "Box[str]"
trusted_official_docs
CPython Docs
T = TypeVar("T") # "Box" does not exist yet, # so we have to use quotes for the forward reference on Python <3.12. # Using ``TypeAlias`` tells the type checker that this is a type alias declaration, # not a variable assignment to a string. BoxOfStrings: TypeAlias = "Box[str]"
T = TypeVar("T") # "Box" does not exist yet, # so we have to use quotes for the forward reference on Python <3.12. # Using ``TypeAlias`` tells the type checker that this is a type alias declaration, # not a variable assignment to a string. BoxOfStrings: TypeAlias = "Box[str]"
python, official-docs, cpython, P0
Local_Trusted_Corpus
67ab7cd3-fc38-4d9a-ab54-eaddc1ffaad1
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,175
supabase-export-v2
ce19595765865c7f
def int_or_str(arg: int | str) -> None: match arg: case int(): print("It's an int") case str(): print("It's a str") case _ as unreachable: assert_never(unreachable) Here, the annotations allow the type checker to infer that the last case can never execute, because ``arg`` is either an :class:`int` or a :class:`str`, ...
trusted_official_docs
CPython Docs
def int_or_str(arg: int | str) -> None: match arg: case int(): print("It's an int") case str(): print("It's a str") case _ as unreachable: assert_never(unreachable) Here, the annotations allow the type checker to infer that the last case can never execute, because ``arg`` is either an :class:`int` or a :class:`str`, ...
def int_or_str(arg: int | str) -> None: match arg: case int(): print("It's an int") case str(): print("It's a str") case _ as unreachable: assert_never(unreachable) Here, the annotations allow the type checker to infer that the last case can never execute, because ``arg`` is either an :class:`int` or a :class:`str`, ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6869457a-ff31-474e-aabb-d16b67826623
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,086
supabase-export-v2
73df31a573b44c63
# Alternative syntax Point2D = TypedDict('Point2D', {'x': int, 'y': int}, total=False) This means that a ``Point2D`` ``TypedDict`` can have any of the keys omitted. A type checker is only expected to support a literal ``False`` or ``True`` as the value of the ``total`` argument. ``True`` is the default, and makes al...
trusted_official_docs
CPython Docs
# Alternative syntax Point2D = TypedDict('Point2D', {'x': int, 'y': int}, total=False) This means that a ``Point2D`` ``TypedDict`` can have any of the keys omitted. A type checker is only expected to support a literal ``False`` or ``True`` as the value of the ``total`` argument. ``True`` is the default, and makes al...
# Alternative syntax Point2D = TypedDict('Point2D', {'x': int, 'y': int}, total=False) This means that a ``Point2D`` ``TypedDict`` can have any of the keys omitted. A type checker is only expected to support a literal ``False`` or ``True`` as the value of the ``total`` argument. ``True`` is the default, and makes al...
python, official-docs, cpython, P0
Local_Trusted_Corpus
68859709-8385-4027-af23-87bf6cb5309b
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,168
supabase-export-v2
c05aa3093956c152
def greet(name: str) -> None: assert_type(name, str) # OK, inferred type of `name` is `str` assert_type(name, int) # type checker error This function is useful for ensuring the type checker's understanding of a script is in line with the developer's intentions::
trusted_official_docs
CPython Docs
def greet(name: str) -> None: assert_type(name, str) # OK, inferred type of `name` is `str` assert_type(name, int) # type checker error This function is useful for ensuring the type checker's understanding of a script is in line with the developer's intentions::
def greet(name: str) -> None: assert_type(name, str) # OK, inferred type of `name` is `str` assert_type(name, int) # type checker error This function is useful for ensuring the type checker's understanding of a script is in line with the developer's intentions::
python, official-docs, cpython, P0
Local_Trusted_Corpus
68bde60f-d092-4ac3-bee1-bde63e0e67a1
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,924
supabase-export-v2
7558f5c55e487d5a
@add_logging def add_two(x: float, y: float) -> float: '''Add two numbers together.''' return x + y Without ``ParamSpec``, the simplest way to annotate this previously was to use a :class:`TypeVar` with upper bound ``Callable[..., Any]``. However this causes two problems:
trusted_official_docs
CPython Docs
@add_logging def add_two(x: float, y: float) -> float: '''Add two numbers together.''' return x + y Without ``ParamSpec``, the simplest way to annotate this previously was to use a :class:`TypeVar` with upper bound ``Callable[..., Any]``. However this causes two problems:
@add_logging def add_two(x: float, y: float) -> float: '''Add two numbers together.''' return x + y Without ``ParamSpec``, the simplest way to annotate this previously was to use a :class:`TypeVar` with upper bound ``Callable[..., Any]``. However this causes two problems:
python, official-docs, cpython, P0
Local_Trusted_Corpus
68c310f1-3c76-40a7-83bb-4e865221fcbf
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,546
supabase-export-v2
db712f1f5af9de2f
Special type that includes only literal strings. Any string literal is compatible with ``LiteralString``, as is another ``LiteralString``. However, an object typed as just ``str`` is not. A string created by composing ``LiteralString``-typed objects is also acceptable as a ``LiteralString``.
trusted_official_docs
CPython Docs
Special type that includes only literal strings. Any string literal is compatible with ``LiteralString``, as is another ``LiteralString``. However, an object typed as just ``str`` is not. A string created by composing ``LiteralString``-typed objects is also acceptable as a ``LiteralString``.
Special type that includes only literal strings. Any string literal is compatible with ``LiteralString``, as is another ``LiteralString``. However, an object typed as just ``str`` is not. A string created by composing ``LiteralString``-typed objects is also acceptable as a ``LiteralString``.
python, official-docs, cpython, P0
Local_Trusted_Corpus
6938f7cf-d945-47e2-9c00-eea97f2caf70
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,808
supabase-export-v2
ac526dcc4a31cf8a
def repeat[T](x: T, n: int) -> Sequence[T]: """Return a list containing n references to x.""" return [x]*n def print_capitalized[S: str](x: S) -> S: """Print x capitalized, and return x.""" print(x.capitalize()) return x
trusted_official_docs
CPython Docs
def repeat[T](x: T, n: int) -> Sequence[T]: """Return a list containing n references to x.""" return [x]*n def print_capitalized[S: str](x: S) -> S: """Print x capitalized, and return x.""" print(x.capitalize()) return x
def repeat[T](x: T, n: int) -> Sequence[T]: """Return a list containing n references to x.""" return [x]*n def print_capitalized[S: str](x: S) -> S: """Print x capitalized, and return x.""" print(x.capitalize()) return x
python, official-docs, cpython, P0
Local_Trusted_Corpus
69a72c12-6a15-4c84-9878-4419856a2f38
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,341
supabase-export-v2
d6f9f9e50983910a
A special constant that is assumed to be ``True`` by 3rd party static type checkers. It's ``False`` at runtime. A module which is expensive to import, and which only contain types used for typing annotations, can be safely imported inside an ``if TYPE_CHECKING:`` block. This prevents the module from actually being i...
trusted_official_docs
CPython Docs
A special constant that is assumed to be ``True`` by 3rd party static type checkers. It's ``False`` at runtime. A module which is expensive to import, and which only contain types used for typing annotations, can be safely imported inside an ``if TYPE_CHECKING:`` block. This prevents the module from actually being i...
A special constant that is assumed to be ``True`` by 3rd party static type checkers. It's ``False`` at runtime. A module which is expensive to import, and which only contain types used for typing annotations, can be safely imported inside an ``if TYPE_CHECKING:`` block. This prevents the module from actually being i...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6a1f5dd3-bf93-4a08-9f3d-e9a129d91ef6
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,518
supabase-export-v2
4bf919bb640e5dd7
``Bucket`` to be implicitly considered a subtype of both ``Sized`` and ``Iterable[int]`` by static type checkers. This is known as *structural subtyping* (or static duck-typing):: from collections.abc import Iterator, Iterable
trusted_official_docs
CPython Docs
``Bucket`` to be implicitly considered a subtype of both ``Sized`` and ``Iterable[int]`` by static type checkers. This is known as *structural subtyping* (or static duck-typing):: from collections.abc import Iterator, Iterable
``Bucket`` to be implicitly considered a subtype of both ``Sized`` and ``Iterable[int]`` by static type checkers. This is known as *structural subtyping* (or static duck-typing):: from collections.abc import Iterator, Iterable
python, official-docs, cpython, P0
Local_Trusted_Corpus
6a691492-b453-45da-8707-2cb67dbbb6de
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,192
supabase-export-v2
59beca4c33dc8b4e
Decorator to mark an object as providing :func:`dataclass <dataclasses.dataclass>`-like behavior. ``dataclass_transform`` may be used to decorate a class, metaclass, or a function that is itself a decorator. The presence of ``@dataclass_transform()`` tells a static type checker that the decorated object performs runt...
trusted_official_docs
CPython Docs
Decorator to mark an object as providing :func:`dataclass <dataclasses.dataclass>`-like behavior. ``dataclass_transform`` may be used to decorate a class, metaclass, or a function that is itself a decorator. The presence of ``@dataclass_transform()`` tells a static type checker that the decorated object performs runt...
Decorator to mark an object as providing :func:`dataclass <dataclasses.dataclass>`-like behavior. ``dataclass_transform`` may be used to decorate a class, metaclass, or a function that is itself a decorator. The presence of ``@dataclass_transform()`` tells a static type checker that the decorated object performs runt...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6b331a6c-d91d-4456-847d-5eecc6b6516a
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,720
supabase-export-v2
0bf9ccb0e760d33c
def func(x: Annotated[int, "metadata"]) -> None: pass ... >>> get_type_hints(func) {'x': <class 'int'>, 'return': <class 'NoneType'>} >>> get_type_hints(func, include_extras=True) {'x': typing.Annotated[int, 'metadata'], 'return': <class 'NoneType'>} At runtime, the metadata associated with an ``Annotated`` type can be...
trusted_official_docs
CPython Docs
def func(x: Annotated[int, "metadata"]) -> None: pass ... >>> get_type_hints(func) {'x': <class 'int'>, 'return': <class 'NoneType'>} >>> get_type_hints(func, include_extras=True) {'x': typing.Annotated[int, 'metadata'], 'return': <class 'NoneType'>} At runtime, the metadata associated with an ``Annotated`` type can be...
def func(x: Annotated[int, "metadata"]) -> None: pass ... >>> get_type_hints(func) {'x': <class 'int'>, 'return': <class 'NoneType'>} >>> get_type_hints(func, include_extras=True) {'x': typing.Annotated[int, 'metadata'], 'return': <class 'NoneType'>} At runtime, the metadata associated with an ``Annotated`` type can be...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6b70d5b3-f714-402f-891a-e1be89fd899f
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,494
supabase-export-v2
19c263790b78b375
The :data:`Any` type ==================== A special kind of type is :data:`Any`. A static type checker will treat every type as being compatible with :data:`Any` and :data:`Any` as being compatible with every type.
trusted_official_docs
CPython Docs
The :data:`Any` type ==================== A special kind of type is :data:`Any`. A static type checker will treat every type as being compatible with :data:`Any` and :data:`Any` as being compatible with every type.
The :data:`Any` type ==================== A special kind of type is :data:`Any`. A static type checker will treat every type as being compatible with :data:`Any` and :data:`Any` as being compatible with every type.
python, official-docs, cpython, P0
Local_Trusted_Corpus
6b9d3970-147f-4c99-872a-26afd130d004
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,226
supabase-export-v2
ce06b58a9c351ffb
.. testcode:: @overload def process(response: None) -> None: ... @overload def process(response: int) -> tuple[int, str]: ... @overload def process(response: bytes) -> str: ... def process(response): ... # actual implementation goes here
trusted_official_docs
CPython Docs
.. testcode:: @overload def process(response: None) -> None: ... @overload def process(response: int) -> tuple[int, str]: ... @overload def process(response: bytes) -> str: ... def process(response): ... # actual implementation goes here
.. testcode:: @overload def process(response: None) -> None: ... @overload def process(response: int) -> tuple[int, str]: ... @overload def process(response: bytes) -> str: ... def process(response): ... # actual implementation goes here
python, official-docs, cpython, P0
Local_Trusted_Corpus
6c5aaab7-5bbe-4cbf-bb1a-993e7f15e2c1
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,766
supabase-export-v2
5b9b97a5b0519b09
if is_str_list(val): # Type of ``val`` is narrowed to ``list[str]``. print(" ".join(val)) else: # Type of ``val`` remains as ``list[object]``. print("Not a list of strings!") ``TypeIs`` and ``TypeGuard`` differ in the following ways:
trusted_official_docs
CPython Docs
if is_str_list(val): # Type of ``val`` is narrowed to ``list[str]``. print(" ".join(val)) else: # Type of ``val`` remains as ``list[object]``. print("Not a list of strings!") ``TypeIs`` and ``TypeGuard`` differ in the following ways:
if is_str_list(val): # Type of ``val`` is narrowed to ``list[str]``. print(" ".join(val)) else: # Type of ``val`` remains as ``list[object]``. print("Not a list of strings!") ``TypeIs`` and ``TypeGuard`` differ in the following ways:
python, official-docs, cpython, P0
Local_Trusted_Corpus
6c96c90c-ebb2-4dfb-b5f0-c0b855223a9e
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,274
supabase-export-v2
6829d39c3634864d
Decorator to mark a class or function as unavailable at runtime. This decorator is itself not available at 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::
trusted_official_docs
CPython Docs
Decorator to mark a class or function as unavailable at runtime. This decorator is itself not available at 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::
Decorator to mark a class or function as unavailable at runtime. This decorator is itself not available at 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::
python, official-docs, cpython, P0
Local_Trusted_Corpus
6d251150-650d-4bab-986c-7de2801708b4
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,115
supabase-export-v2
3d6d076d60e8ecda
``Point2D.__required_keys__`` and ``Point2D.__optional_keys__`` return :class:`frozenset` objects containing required and non-required keys, respectively. Keys marked with :data:`Required` will always appear in ``__required_keys__`` and keys marked with :data:`NotRequired` will always appear in ``__optional_keys__``.
trusted_official_docs
CPython Docs
``Point2D.__required_keys__`` and ``Point2D.__optional_keys__`` return :class:`frozenset` objects containing required and non-required keys, respectively. Keys marked with :data:`Required` will always appear in ``__required_keys__`` and keys marked with :data:`NotRequired` will always appear in ``__optional_keys__``.
``Point2D.__required_keys__`` and ``Point2D.__optional_keys__`` return :class:`frozenset` objects containing required and non-required keys, respectively. Keys marked with :data:`Required` will always appear in ``__required_keys__`` and keys marked with :data:`NotRequired` will always appear in ``__optional_keys__``.
python, official-docs, cpython, P0
Local_Trusted_Corpus
6d86bc32-2dbe-414b-af0d-ed4725ddd4cc
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,443
supabase-export-v2
101915a0b49eb904
the class ``LoggedVar`` is parameterised around a single :ref:`type variable <typevar>` ``T`` . This also makes ``T`` valid as a type within the class body. Generic classes implicitly inherit from :class:`Generic`. For compatibility with Python 3.11 and lower, it is also possible to inherit explicitly from :class:`Gene...
trusted_official_docs
CPython Docs
the class ``LoggedVar`` is parameterised around a single :ref:`type variable <typevar>` ``T`` . This also makes ``T`` valid as a type within the class body. Generic classes implicitly inherit from :class:`Generic`. For compatibility with Python 3.11 and lower, it is also possible to inherit explicitly from :class:`Gene...
the class ``LoggedVar`` is parameterised around a single :ref:`type variable <typevar>` ``T`` . This also makes ``T`` valid as a type within the class body. Generic classes implicitly inherit from :class:`Generic`. For compatibility with Python 3.11 and lower, it is also possible to inherit explicitly from :class:`Gene...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6dd577cf-54db-4be9-8734-49378ac81e00
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,837
supabase-export-v2
7f6374c12babe002
.. versionchanged:: 3.12 For type variables created through :ref:`type parameter syntax <type-params>`, the bound is evaluated only when the attribute is accessed, not when the type variable is created (see :ref:`lazy-evaluation`).
trusted_official_docs
CPython Docs
.. versionchanged:: 3.12 For type variables created through :ref:`type parameter syntax <type-params>`, the bound is evaluated only when the attribute is accessed, not when the type variable is created (see :ref:`lazy-evaluation`).
.. versionchanged:: 3.12 For type variables created through :ref:`type parameter syntax <type-params>`, the bound is evaluated only when the attribute is accessed, not when the type variable is created (see :ref:`lazy-evaluation`).
python, official-docs, cpython, P0
Local_Trusted_Corpus
6e3e758c-b522-42f7-92a4-9fa4a59e6630
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,359
supabase-export-v2
f4c4c45e77e7443c
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. If a literal ellipsis ``...`` is given as the argument list, it indicates that a callable with any arbitrary parameter list would be acceptable:
trusted_official_docs
CPython Docs
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. If a literal ellipsis ``...`` is given as the argument list, it indicates that a callable with any arbitrary parameter list would be acceptable:
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. If a literal ellipsis ``...`` is given as the argument list, it indicates that a callable with any arbitrary parameter list would be acceptable:
python, official-docs, cpython, P0
Local_Trusted_Corpus
6f23e500-19f1-440c-860a-15897b15f245
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,394
supabase-export-v2
e84421fefa8c1a5d
to be strings, # and that all values in ``z`` are meant to be either strings or ints z: Mapping[str, str | int] = {} :class:`list` only accepts one type argument, so a type checker would emit an error on the ``y`` assignment above. Similarly, :class:`~collections.abc.Mapping` only accepts two type arguments: the first ...
trusted_official_docs
CPython Docs
to be strings, # and that all values in ``z`` are meant to be either strings or ints z: Mapping[str, str | int] = {} :class:`list` only accepts one type argument, so a type checker would emit an error on the ``y`` assignment above. Similarly, :class:`~collections.abc.Mapping` only accepts two type arguments: the first ...
to be strings, # and that all values in ``z`` are meant to be either strings or ints z: Mapping[str, str | int] = {} :class:`list` only accepts one type argument, so a type checker would emit an error on the ``y`` assignment above. Similarly, :class:`~collections.abc.Mapping` only accepts two type arguments: the first ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6f598ac3-1ff3-4453-953f-7fafabe29e9f
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,824
supabase-export-v2
eb14294f0ddd5dc4
b = concatenate(StringSubclass('one'), StringSubclass('two')) reveal_type(b) # revealed type is str, despite StringSubclass being passed in c = concatenate('one', b'two') # error: type variable 'A' can be either str or bytes in a function call, but not both
trusted_official_docs
CPython Docs
b = concatenate(StringSubclass('one'), StringSubclass('two')) reveal_type(b) # revealed type is str, despite StringSubclass being passed in c = concatenate('one', b'two') # error: type variable 'A' can be either str or bytes in a function call, but not both
b = concatenate(StringSubclass('one'), StringSubclass('two')) reveal_type(b) # revealed type is str, despite StringSubclass being passed in c = concatenate('one', b'two') # error: type variable 'A' can be either str or bytes in a function call, but not both
python, official-docs, cpython, P0
Local_Trusted_Corpus
6f61bd4a-6754-493d-a570-dc90b462e286
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,551
supabase-export-v2
f6565e22e44e63c9
arbitrary user-generated strings could generate problems. For example, the two cases above that generate type checker errors could be vulnerable to an SQL injection attack. See :pep:`675` for more details.
trusted_official_docs
CPython Docs
arbitrary user-generated strings could generate problems. For example, the two cases above that generate type checker errors could be vulnerable to an SQL injection attack. See :pep:`675` for more details.
arbitrary user-generated strings could generate problems. For example, the two cases above that generate type checker errors could be vulnerable to an SQL injection attack. See :pep:`675` for more details.
python, official-docs, cpython, P0
Local_Trusted_Corpus
6fd2475d-9a8a-4d0d-a923-c08ede72c6cc
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,698
supabase-export-v2
2469ad6e2623bbc7
T1 = Annotated[int, ValueRange(-10, 5)] T2 = Annotated[T1, ValueRange(-20, 3)] The first argument to ``Annotated`` must be a valid type. Multiple metadata elements can be supplied as ``Annotated`` supports variadic arguments. The order of the metadata elements is preserved and matters for equality checks::
trusted_official_docs
CPython Docs
T1 = Annotated[int, ValueRange(-10, 5)] T2 = Annotated[T1, ValueRange(-20, 3)] The first argument to ``Annotated`` must be a valid type. Multiple metadata elements can be supplied as ``Annotated`` supports variadic arguments. The order of the metadata elements is preserved and matters for equality checks::
T1 = Annotated[int, ValueRange(-10, 5)] T2 = Annotated[T1, ValueRange(-20, 3)] The first argument to ``Annotated`` must be a valid type. Multiple metadata elements can be supplied as ``Annotated`` supports variadic arguments. The order of the metadata elements is preserved and matters for equality checks::
python, official-docs, cpython, P0
Local_Trusted_Corpus
706f41a3-a3d9-4d1c-8254-65a89d56fb7f
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,047
supabase-export-v2
484e44f0229535a2
.. versionadded:: 3.8 .. deprecated-removed:: 3.15 3.20 It is deprecated to call :func:`isinstance` and :func:`issubclass` checks on protocol classes that were not explicitly decorated with :func:`!runtime_checkable` but that inherit from a runtime-checkable protocol class. This will throw a :exc:`TypeError` in Pyt...
trusted_official_docs
CPython Docs
.. versionadded:: 3.8 .. deprecated-removed:: 3.15 3.20 It is deprecated to call :func:`isinstance` and :func:`issubclass` checks on protocol classes that were not explicitly decorated with :func:`!runtime_checkable` but that inherit from a runtime-checkable protocol class. This will throw a :exc:`TypeError` in Pyt...
.. versionadded:: 3.8 .. deprecated-removed:: 3.15 3.20 It is deprecated to call :func:`isinstance` and :func:`issubclass` checks on protocol classes that were not explicitly decorated with :func:`!runtime_checkable` but that inherit from a runtime-checkable protocol class. This will throw a :exc:`TypeError` in Pyt...
python, official-docs, cpython, P0
Local_Trusted_Corpus
7189892d-3ec1-4a2d-afaa-855c2a98e8d1
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,812
supabase-export-v2
f16f6f19edaef21a
explicitly marked covariant or contravariant by passing ``covariant=True`` or ``contravariant=True``. By default, manually created type variables are invariant. See :pep:`484` and :pep:`695` for more details. Bounded type variables and constrained type variables have different semantics in several important ways. Usin...
trusted_official_docs
CPython Docs
explicitly marked covariant or contravariant by passing ``covariant=True`` or ``contravariant=True``. By default, manually created type variables are invariant. See :pep:`484` and :pep:`695` for more details. Bounded type variables and constrained type variables have different semantics in several important ways. Usin...
explicitly marked covariant or contravariant by passing ``covariant=True`` or ``contravariant=True``. By default, manually created type variables are invariant. See :pep:`484` and :pep:`695` for more details. Bounded type variables and constrained type variables have different semantics in several important ways. Usin...
python, official-docs, cpython, P0
Local_Trusted_Corpus
71c1cf0e-2c29-4528-bed4-61a5195391b5
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,904
supabase-export-v2
487e6b5ab5c95ad3
.. method:: has_default() Return whether or not the type variable tuple 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 tuple 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 tuple 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
72645427-a0c5-41ee-81b7-d0c19b8f43b8
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,347
supabase-export-v2
feb55f9860ded1e3
``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. .. versionchanged:: 3.11 The performance of calling ``NewType`` has been restored to its level in Python 3.9.
trusted_official_docs
CPython Docs
``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. .. versionchanged:: 3.11 The performance of calling ``NewType`` has been restored to its level in Python 3.9.
``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. .. versionchanged:: 3.11 The performance of calling ``NewType`` has been restored to its level in Python 3.9.
python, official-docs, cpython, P0
Local_Trusted_Corpus
73eb7dcf-2f45-4bb7-b09a-71812b98fe2b
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,425
supabase-export-v2
ab4a747ced5e0efd
def infinite_stream(start: int) -> Generator[int, None, None]: while True: yield start start += 1 Simple generators that only ever yield values can also be annotated as having a return type of either :class:`Iterable[YieldType] <collections.abc.Iterable>` or :class:`Iterator[YieldType] <collections.abc.Iterator>`::
trusted_official_docs
CPython Docs
def infinite_stream(start: int) -> Generator[int, None, None]: while True: yield start start += 1 Simple generators that only ever yield values can also be annotated as having a return type of either :class:`Iterable[YieldType] <collections.abc.Iterable>` or :class:`Iterator[YieldType] <collections.abc.Iterator>`::
def infinite_stream(start: int) -> Generator[int, None, None]: while True: yield start start += 1 Simple generators that only ever yield values can also be annotated as having a return type of either :class:`Iterable[YieldType] <collections.abc.Iterable>` or :class:`Iterator[YieldType] <collections.abc.Iterator>`::
python, official-docs, cpython, P0
Local_Trusted_Corpus
7472403f-027a-42b1-9af7-47df4a4c79f7
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,281
supabase-export-v2
a802aa05006c6646
Return a dictionary containing type hints for a function, method, module, class object, or other callable object. This is often the same as :func:`annotationlib.get_annotations`, but this function makes the following changes to the annotations dictionary:
trusted_official_docs
CPython Docs
Return a dictionary containing type hints for a function, method, module, class object, or other callable object. This is often the same as :func:`annotationlib.get_annotations`, but this function makes the following changes to the annotations dictionary:
Return a dictionary containing type hints for a function, method, module, class object, or other callable object. This is often the same as :func:`annotationlib.get_annotations`, but this function makes the following changes to the annotations dictionary:
python, official-docs, cpython, P0
Local_Trusted_Corpus
74a698df-0c7c-434c-ab98-3af9ffda071f
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,269
supabase-export-v2
acbeccb6269b44ef
Type checkers can use knowledge of disjoint bases to detect unreachable code and determine when two types can overlap. The corresponding runtime concept is a solid base (see :ref:`multiple-inheritance`). Classes that are solid bases at runtime can be marked with ``@disjoint_base`` in stub files. Users may also mark oth...
trusted_official_docs
CPython Docs
Type checkers can use knowledge of disjoint bases to detect unreachable code and determine when two types can overlap. The corresponding runtime concept is a solid base (see :ref:`multiple-inheritance`). Classes that are solid bases at runtime can be marked with ``@disjoint_base`` in stub files. Users may also mark oth...
Type checkers can use knowledge of disjoint bases to detect unreachable code and determine when two types can overlap. The corresponding runtime concept is a solid base (see :ref:`multiple-inheritance`). Classes that are solid bases at runtime can be marked with ``@disjoint_base`` in stub files. Users may also mark oth...
python, official-docs, cpython, P0
Local_Trusted_Corpus
764b50f0-9865-4fcf-a271-66bfd9210aa3
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,223
supabase-export-v2
c0e93b63d1d522c9
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 same function/method). ``@overload``-decorated definitions are for the benefit of the type checker only, since they will be ove...
trusted_official_docs
CPython Docs
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 same function/method). ``@overload``-decorated definitions are for the benefit of the type checker only, since they will be ove...
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 same function/method). ``@overload``-decorated definitions are for the benefit of the type checker only, since they will be ove...
python, official-docs, cpython, P0
Local_Trusted_Corpus
785e7d5f-549b-471a-b70f-a75c706ffde3
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,861
supabase-export-v2
f72c6fca97302823
Type variable tuple. A specialized form of :ref:`type variable <typevar>` that enables *variadic* generics. Type variable tuples can be declared in :ref:`type parameter lists <type-params>` using a single asterisk (``*``) before the name::
trusted_official_docs
CPython Docs
Type variable tuple. A specialized form of :ref:`type variable <typevar>` that enables *variadic* generics. Type variable tuples can be declared in :ref:`type parameter lists <type-params>` using a single asterisk (``*``) before the name::
Type variable tuple. A specialized form of :ref:`type variable <typevar>` that enables *variadic* generics. Type variable tuples can be declared in :ref:`type parameter lists <type-params>` using a single asterisk (``*``) before the name::
python, official-docs, cpython, P0
Local_Trusted_Corpus
78a23354-a12b-4f62-b32e-7d6bf0657bf0
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,325
supabase-export-v2
a5c409746859afcc
UserId = NewType('UserId', int) some_id = UserId(524313) The static 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::
trusted_official_docs
CPython Docs
UserId = NewType('UserId', int) some_id = UserId(524313) The static 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::
UserId = NewType('UserId', int) some_id = UserId(524313) The static 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::
python, official-docs, cpython, P0
Local_Trusted_Corpus
7952b7e3-d382-4ad2-9b14-da8765889021
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,482
supabase-export-v2
698eeca00d4bbf94
aliases is new in version 3.12. Previously, generic classes had to explicitly inherit from :class:`Generic` or contain a type variable in one of their bases. User-defined generics for parameter expressions are also supported via parameter specification variables in the form ``[**P]``. The behavior is consistent with ty...
trusted_official_docs
CPython Docs
aliases is new in version 3.12. Previously, generic classes had to explicitly inherit from :class:`Generic` or contain a type variable in one of their bases. User-defined generics for parameter expressions are also supported via parameter specification variables in the form ``[**P]``. The behavior is consistent with ty...
aliases is new in version 3.12. Previously, generic classes had to explicitly inherit from :class:`Generic` or contain a type variable in one of their bases. User-defined generics for parameter expressions are also supported via parameter specification variables in the form ``[**P]``. The behavior is consistent with ty...
python, official-docs, cpython, P0
Local_Trusted_Corpus
7a424051-ed66-49e8-9703-3601bc3d6234
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,401
supabase-export-v2
0fa6c79ec164e0dd
the literal ellipsis ``...``: ``tuple[T, ...]``. To denote an empty tuple, use ``tuple[()]``. Using plain ``tuple`` as an annotation is equivalent to using ``tuple[Any, ...]``:: x: tuple[int, ...] = (1, 2) # These reassignments are OK: ``tuple[int, ...]`` indicates x can be of any length x = (1, 2, 3) x = () # This...
trusted_official_docs
CPython Docs
the literal ellipsis ``...``: ``tuple[T, ...]``. To denote an empty tuple, use ``tuple[()]``. Using plain ``tuple`` as an annotation is equivalent to using ``tuple[Any, ...]``:: x: tuple[int, ...] = (1, 2) # These reassignments are OK: ``tuple[int, ...]`` indicates x can be of any length x = (1, 2, 3) x = () # This...
the literal ellipsis ``...``: ``tuple[T, ...]``. To denote an empty tuple, use ``tuple[()]``. Using plain ``tuple`` as an annotation is equivalent to using ``tuple[Any, ...]``:: x: tuple[int, ...] = (1, 2) # These reassignments are OK: ``tuple[int, ...]`` indicates x can be of any length x = (1, 2, 3) x = () # This...
python, official-docs, cpython, P0
Local_Trusted_Corpus
7b3473b5-bac1-4538-9baf-d2a7a9e7fe34
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,379
supabase-export-v2
e00cd2182615057d
Mapping[str, str] indicates that all keys and all values in the mapping # must be strings. def notify_by_email(employees: Sequence[Employee], overrides: Mapping[str, str]) -> None: ... Generic functions and classes can be parameterized by using :ref:`type parameter syntax <type-params>`::
trusted_official_docs
CPython Docs
Mapping[str, str] indicates that all keys and all values in the mapping # must be strings. def notify_by_email(employees: Sequence[Employee], overrides: Mapping[str, str]) -> None: ... Generic functions and classes can be parameterized by using :ref:`type parameter syntax <type-params>`::
Mapping[str, str] indicates that all keys and all values in the mapping # must be strings. def notify_by_email(employees: Sequence[Employee], overrides: Mapping[str, str]) -> None: ... Generic functions and classes can be parameterized by using :ref:`type parameter syntax <type-params>`::
python, official-docs, cpython, P0
Local_Trusted_Corpus
7b5309ad-511f-4b12-9e0d-19ec1c6ee9fd
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,616
supabase-export-v2
8d7799fa91e5fb8e
``Optional[X]`` is equivalent to ``X | None`` (or ``Union[X, None]``). Note that this is not the same concept as an optional argument, which is one that has 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::
trusted_official_docs
CPython Docs
``Optional[X]`` is equivalent to ``X | None`` (or ``Union[X, None]``). Note that this is not the same concept as an optional argument, which is one that has 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::
``Optional[X]`` is equivalent to ``X | None`` (or ``Union[X, None]``). Note that this is not the same concept as an optional argument, which is one that has 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::
python, official-docs, cpython, P0
Local_Trusted_Corpus
7bdc29d9-e581-4589-8cfa-3881caa27196
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,442
supabase-export-v2
69194ad6307f0f8e
def log(self, message: str) -> None: self.logger.info('%s: %s', self.name, message) This syntax indicates that the class ``LoggedVar`` is parameterised around a single :ref:`type variable <typevar>` ``T`` . This also makes ``T`` valid as a type within the class body.
trusted_official_docs
CPython Docs
def log(self, message: str) -> None: self.logger.info('%s: %s', self.name, message) This syntax indicates that the class ``LoggedVar`` is parameterised around a single :ref:`type variable <typevar>` ``T`` . This also makes ``T`` valid as a type within the class body.
def log(self, message: str) -> None: self.logger.info('%s: %s', self.name, message) This syntax indicates that the class ``LoggedVar`` is parameterised around a single :ref:`type variable <typevar>` ``T`` . This also makes ``T`` valid as a type within the class body.
python, official-docs, cpython, P0
Local_Trusted_Corpus
7cfc9681-3603-4079-b38b-4713a892ebc7
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,439
supabase-export-v2
4d5bac75ccefe57d
class LoggedVar[T]: def __init__(self, value: T, name: str, logger: Logger) -> None: self.name = name self.logger = logger self.value = value def set(self, new: T) -> None: self.log('Set ' + repr(self.value)) self.value = new
trusted_official_docs
CPython Docs
class LoggedVar[T]: def __init__(self, value: T, name: str, logger: Logger) -> None: self.name = name self.logger = logger self.value = value def set(self, new: T) -> None: self.log('Set ' + repr(self.value)) self.value = new
class LoggedVar[T]: def __init__(self, value: T, name: str, logger: Logger) -> None: self.name = name self.logger = logger self.value = value def set(self, new: T) -> None: self.log('Set ' + repr(self.value)) self.value = new
python, official-docs, cpython, P0
Local_Trusted_Corpus
7df85e0e-291f-40d8-b348-00e1d3eb4064
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,539
supabase-export-v2
cea26a6d45748ce7
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 Note that, despite its name, ``AnyStr`` has nothing to do with the :class:`Any` type, nor does it mean "any string". In particular, ``AnyStr`` and ``str | bytes...
trusted_official_docs
CPython Docs
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 Note that, despite its name, ``AnyStr`` has nothing to do with the :class:`Any` type, nor does it mean "any string". In particular, ``AnyStr`` and ``str | bytes...
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 Note that, despite its name, ``AnyStr`` has nothing to do with the :class:`Any` type, nor does it mean "any string". In particular, ``AnyStr`` and ``str | bytes...
python, official-docs, cpython, P0
Local_Trusted_Corpus
7ead20f2-e69a-445d-8a30-4f2ef03dfa60
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,352
supabase-export-v2
c99d876bbcfa70c1
at least two releases prior to removal. The aliases are guaranteed to remain in the :mod:`!typing` module without deprecation warnings until at least Python 3.14. Type checkers are encouraged to flag uses of the deprecated types if the program they are checking targets a minimum Python version of 3.9 or newer.
trusted_official_docs
CPython Docs
at least two releases prior to removal. The aliases are guaranteed to remain in the :mod:`!typing` module without deprecation warnings until at least Python 3.14. Type checkers are encouraged to flag uses of the deprecated types if the program they are checking targets a minimum Python version of 3.9 or newer.
at least two releases prior to removal. The aliases are guaranteed to remain in the :mod:`!typing` module without deprecation warnings until at least Python 3.14. Type checkers are encouraged to flag uses of the deprecated types if the program they are checking targets a minimum Python version of 3.9 or newer.
python, official-docs, cpython, P0
Local_Trusted_Corpus
7ef8a611-ba6b-45ef-9259-c0121cba0b10
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,630
supabase-export-v2
e1d239a452082b28
@with_lock def sum_threadsafe(lock: Lock, numbers: list[float]) -> float: '''Add a list of numbers together in a thread-safe manner.''' with lock: return sum(numbers) # We don't need to pass in the lock ourselves thanks to the decorator. sum_threadsafe([1.1, 2.2, 3.3])
trusted_official_docs
CPython Docs
@with_lock def sum_threadsafe(lock: Lock, numbers: list[float]) -> float: '''Add a list of numbers together in a thread-safe manner.''' with lock: return sum(numbers) # We don't need to pass in the lock ourselves thanks to the decorator. sum_threadsafe([1.1, 2.2, 3.3])
@with_lock def sum_threadsafe(lock: Lock, numbers: list[float]) -> float: '''Add a list of numbers together in a thread-safe manner.''' with lock: return sum(numbers) # We don't need to pass in the lock ourselves thanks to the decorator. sum_threadsafe([1.1, 2.2, 3.3])
python, official-docs, cpython, P0
Local_Trusted_Corpus
7fc4e3dd-32b8-461b-ba0a-65b10abf11b4
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,506
supabase-export-v2
71f2e0c7475e6f3b
:data:`Any`, every type is a subtype of :class:`object`. However, unlike :data:`Any`, the reverse is not true: :class:`object` is *not* a subtype of every other type. That means when the type of a value is :class:`object`, a type checker will reject almost all operations on it, and assigning it to a variable (or using ...
trusted_official_docs
CPython Docs
:data:`Any`, every type is a subtype of :class:`object`. However, unlike :data:`Any`, the reverse is not true: :class:`object` is *not* a subtype of every other type. That means when the type of a value is :class:`object`, a type checker will reject almost all operations on it, and assigning it to a variable (or using ...
:data:`Any`, every type is a subtype of :class:`object`. However, unlike :data:`Any`, the reverse is not true: :class:`object` is *not* a subtype of every other type. That means when the type of a value is :class:`object`, a type checker will reject almost all operations on it, and assigning it to a variable (or using ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
7fe48fa7-8904-48d3-aee7-8dd2fc41095d
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,481
supabase-export-v2
35ab9f208983a2bd
.. versionchanged:: 3.7 :class:`Generic` no longer has a custom metaclass. .. versionchanged:: 3.12 Syntactic support for generics and type aliases is new in version 3.12. Previously, generic classes had to explicitly inherit from :class:`Generic` or contain a type variable in one of their bases.
trusted_official_docs
CPython Docs
.. versionchanged:: 3.7 :class:`Generic` no longer has a custom metaclass. .. versionchanged:: 3.12 Syntactic support for generics and type aliases is new in version 3.12. Previously, generic classes had to explicitly inherit from :class:`Generic` or contain a type variable in one of their bases.
.. versionchanged:: 3.7 :class:`Generic` no longer has a custom metaclass. .. versionchanged:: 3.12 Syntactic support for generics and type aliases is new in version 3.12. Previously, generic classes had to explicitly inherit from :class:`Generic` or contain a type variable in one of their bases.
python, official-docs, cpython, P0
Local_Trusted_Corpus
8240a0ad-a6b2-47e5-8ada-3aeccdd8a1f0
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,177
supabase-export-v2
2117b57ed194ebdc
a call to ``assert_never`` to pass type checking, the inferred type of the argument passed in must be the bottom type, :data:`Never`, and nothing else. At runtime, this throws an exception when called.
trusted_official_docs
CPython Docs
a call to ``assert_never`` to pass type checking, the inferred type of the argument passed in must be the bottom type, :data:`Never`, and nothing else. At runtime, this throws an exception when called.
a call to ``assert_never`` to pass type checking, the inferred type of the argument passed in must be the bottom type, :data:`Never`, and nothing else. At runtime, this throws an exception when called.
python, official-docs, cpython, P0
Local_Trusted_Corpus
8294a9b8-3f48-44a5-907f-bd078308d73e
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,550
supabase-export-v2
6dbf25fba39d2ecb
FROM " + literal_string) # OK run_query(arbitrary_string) # type checker error run_query( # type checker error f"SELECT * FROM students WHERE name = {arbitrary_string}" ) ``LiteralString`` is useful for sensitive APIs where arbitrary user-generated strings could generate problems. For example, the two cases above tha...
trusted_official_docs
CPython Docs
FROM " + literal_string) # OK run_query(arbitrary_string) # type checker error run_query( # type checker error f"SELECT * FROM students WHERE name = {arbitrary_string}" ) ``LiteralString`` is useful for sensitive APIs where arbitrary user-generated strings could generate problems. For example, the two cases above tha...
FROM " + literal_string) # OK run_query(arbitrary_string) # type checker error run_query( # type checker error f"SELECT * FROM students WHERE name = {arbitrary_string}" ) ``LiteralString`` is useful for sensitive APIs where arbitrary user-generated strings could generate problems. For example, the two cases above tha...
python, official-docs, cpython, P0
Local_Trusted_Corpus
83e38560-a253-4a9a-b141-59a124a94a74
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,489
supabase-export-v2
808da343320a6a63
forms ``X[[Type1, Type2, ...]]`` and also ``X[Type1, Type2, ...]`` for aesthetic reasons. Internally, the latter is converted to the former, so the following are equivalent:: >>> class X[**P]: ... ... >>> X[int, str] __main__.X[[int, str]] >>> X[[int, str]] __main__.X[[int, str]]
trusted_official_docs
CPython Docs
forms ``X[[Type1, Type2, ...]]`` and also ``X[Type1, Type2, ...]`` for aesthetic reasons. Internally, the latter is converted to the former, so the following are equivalent:: >>> class X[**P]: ... ... >>> X[int, str] __main__.X[[int, str]] >>> X[[int, str]] __main__.X[[int, str]]
forms ``X[[Type1, Type2, ...]]`` and also ``X[Type1, Type2, ...]`` for aesthetic reasons. Internally, the latter is converted to the former, so the following are equivalent:: >>> class X[**P]: ... ... >>> X[int, str] __main__.X[[int, str]] >>> X[[int, str]] __main__.X[[int, str]]
python, official-docs, cpython, P0
Local_Trusted_Corpus
8416f2f4-5e04-452a-8873-fdf3fe0c2808
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,775
supabase-export-v2
4e9aec529515b712
# In older versions of Python, TypeVarTuple and Unpack # are located in the `typing_extensions` backports package. from typing_extensions import TypeVarTuple, Unpack Ts = TypeVarTuple('Ts') tup: tuple[*Ts] # Syntax error on Python <= 3.10! tup: tuple[Unpack[Ts]] # Semantically equivalent, and backwards-compatible
trusted_official_docs
CPython Docs
# In older versions of Python, TypeVarTuple and Unpack # are located in the `typing_extensions` backports package. from typing_extensions import TypeVarTuple, Unpack Ts = TypeVarTuple('Ts') tup: tuple[*Ts] # Syntax error on Python <= 3.10! tup: tuple[Unpack[Ts]] # Semantically equivalent, and backwards-compatible
# In older versions of Python, TypeVarTuple and Unpack # are located in the `typing_extensions` backports package. from typing_extensions import TypeVarTuple, Unpack Ts = TypeVarTuple('Ts') tup: tuple[*Ts] # Syntax error on Python <= 3.10! tup: tuple[Unpack[Ts]] # Semantically equivalent, and backwards-compatible
python, official-docs, cpython, P0
Local_Trusted_Corpus
84b9c4ce-eced-482f-864c-a48ae317ceab
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,185
supabase-export-v2
91d468d20a0bebf8
This can be useful when you want to debug how your type checker handles a particular piece of code. At runtime, 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)::
trusted_official_docs
CPython Docs
This can be useful when you want to debug how your type checker handles a particular piece of code. At runtime, 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)::
This can be useful when you want to debug how your type checker handles a particular piece of code. At runtime, 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)::
python, official-docs, cpython, P0
Local_Trusted_Corpus
85666cc7-11b6-4a32-b948-4c7303cac82b
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,062
supabase-export-v2
163b42f9bf51f4f3
.. note:: An :func:`isinstance` check against a runtime-checkable protocol can be surprisingly slow compared to an ``isinstance()`` check against a non-protocol class. Consider using alternative idioms such as :func:`hasattr` calls for structural checks in performance-sensitive code.
trusted_official_docs
CPython Docs
.. note:: An :func:`isinstance` check against a runtime-checkable protocol can be surprisingly slow compared to an ``isinstance()`` check against a non-protocol class. Consider using alternative idioms such as :func:`hasattr` calls for structural checks in performance-sensitive code.
.. note:: An :func:`isinstance` check against a runtime-checkable protocol can be surprisingly slow compared to an ``isinstance()`` check against a non-protocol class. Consider using alternative idioms such as :func:`hasattr` calls for structural checks in performance-sensitive code.
python, official-docs, cpython, P0
Local_Trusted_Corpus
85a51efc-549e-48d4-8be4-8583d7935fa6
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,926
supabase-export-v2
4a7d9330108fa7e4
in the body of the ``add_logging`` decorator when returning the ``inner`` function, or the static type checker must be told to ignore the ``return inner``. .. attribute:: args .. attribute:: kwargs
trusted_official_docs
CPython Docs
in the body of the ``add_logging`` decorator when returning the ``inner`` function, or the static type checker must be told to ignore the ``return inner``. .. attribute:: args .. attribute:: kwargs
in the body of the ``add_logging`` decorator when returning the ``inner`` function, or the static type checker must be told to ignore the ``return inner``. .. attribute:: args .. attribute:: kwargs
python, official-docs, cpython, P0
Local_Trusted_Corpus
867b69ab-d951-4c36-933c-1cfc0aee92db
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,874
supabase-export-v2
ca900e467dd915d6
x: Ts # Not valid x: tuple[Ts] # Not valid x: tuple[*Ts] # The correct way to do it Type variable tuples can be used in the same contexts as normal type variables. For example, in class definitions, arguments, and return types::
trusted_official_docs
CPython Docs
x: Ts # Not valid x: tuple[Ts] # Not valid x: tuple[*Ts] # The correct way to do it Type variable tuples can be used in the same contexts as normal type variables. For example, in class definitions, arguments, and return types::
x: Ts # Not valid x: tuple[Ts] # Not valid x: tuple[*Ts] # The correct way to do it Type variable tuples can be used in the same contexts as normal type variables. For example, in class definitions, arguments, and return types::
python, official-docs, cpython, P0
Local_Trusted_Corpus
87cc5e32-4ed8-4341-8c93-a9c290fd6239
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,328
supabase-export-v2
fa7a021ba7e69e2e
.. versionadded:: 3.7.4 .. versionchanged:: 3.14 This is now an alias for :class:`annotationlib.ForwardRef`. Several undocumented behaviors of this class have been changed; for example, after a ``ForwardRef`` has been evaluated, the evaluated value is no longer cached.
trusted_official_docs
CPython Docs
.. versionadded:: 3.7.4 .. versionchanged:: 3.14 This is now an alias for :class:`annotationlib.ForwardRef`. Several undocumented behaviors of this class have been changed; for example, after a ``ForwardRef`` has been evaluated, the evaluated value is no longer cached.
.. versionadded:: 3.7.4 .. versionchanged:: 3.14 This is now an alias for :class:`annotationlib.ForwardRef`. Several undocumented behaviors of this class have been changed; for example, after a ``ForwardRef`` has been evaluated, the evaluated value is no longer cached.
python, official-docs, cpython, P0
Local_Trusted_Corpus
87d14128-57d9-42d7-bdf6-937e96cdbcb7
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,297
supabase-export-v2
9a83097436c71569
def surface_area_of_cube(edge_length: float) -> str: return f"The surface area of the cube is {6 * edge_length ** 2}." The function ``surface_area_of_cube`` takes an argument expected to be an instance of :class:`float`, as indicated by the :term:`type hint` ``edge_length: float``. The function is expected to return an...
trusted_official_docs
CPython Docs
def surface_area_of_cube(edge_length: float) -> str: return f"The surface area of the cube is {6 * edge_length ** 2}." The function ``surface_area_of_cube`` takes an argument expected to be an instance of :class:`float`, as indicated by the :term:`type hint` ``edge_length: float``. The function is expected to return an...
def surface_area_of_cube(edge_length: float) -> str: return f"The surface area of the cube is {6 * edge_length ** 2}." The function ``surface_area_of_cube`` takes an argument expected to be an instance of :class:`float`, as indicated by the :term:`type hint` ``edge_length: float``. The function is expected to return an...
python, official-docs, cpython, P0
Local_Trusted_Corpus
885b3347-edcb-433e-a61a-b2c6969cbec4
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,654
supabase-export-v2
b1281c7b00a94b47
.. versionadded:: 3.8 .. versionchanged:: 3.9.1 ``Literal`` now de-duplicates parameters. Equality comparisons of ``Literal`` objects are no longer order dependent. ``Literal`` objects will now raise a :exc:`TypeError` exception during equality comparisons if one of their parameters are not :term:`hashable`.
trusted_official_docs
CPython Docs
.. versionadded:: 3.8 .. versionchanged:: 3.9.1 ``Literal`` now de-duplicates parameters. Equality comparisons of ``Literal`` objects are no longer order dependent. ``Literal`` objects will now raise a :exc:`TypeError` exception during equality comparisons if one of their parameters are not :term:`hashable`.
.. versionadded:: 3.8 .. versionchanged:: 3.9.1 ``Literal`` now de-duplicates parameters. Equality comparisons of ``Literal`` objects are no longer order dependent. ``Literal`` objects will now raise a :exc:`TypeError` exception during equality comparisons if one of their parameters are not :term:`hashable`.
python, official-docs, cpython, P0
Local_Trusted_Corpus
88fdb6ac-0b1f-4079-b228-065080c978a7
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,761
supabase-export-v2
b8fea6b49997aeaf
Using ``-> TypeGuard`` 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 type inside ``TypeGuard``.
trusted_official_docs
CPython Docs
Using ``-> TypeGuard`` 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 type inside ``TypeGuard``.
Using ``-> TypeGuard`` 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 type inside ``TypeGuard``.
python, official-docs, cpython, P0
Local_Trusted_Corpus
892f04bc-3ab8-4660-86c1-f3f346930108
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,953
supabase-export-v2
3af1fe569758e2db
instance of ``ParamSpecArgs``, and ``P.kwargs`` is an instance of ``ParamSpecKwargs``. They are intended for runtime introspection and have no special meaning to static type checkers. Calling :func:`get_origin` on either of these objects will return the original ``ParamSpec``:
trusted_official_docs
CPython Docs
instance of ``ParamSpecArgs``, and ``P.kwargs`` is an instance of ``ParamSpecKwargs``. They are intended for runtime introspection and have no special meaning to static type checkers. Calling :func:`get_origin` on either of these objects will return the original ``ParamSpec``:
instance of ``ParamSpecArgs``, and ``P.kwargs`` is an instance of ``ParamSpecKwargs``. They are intended for runtime introspection and have no special meaning to static type checkers. Calling :func:`get_origin` on either of these objects will return the original ``ParamSpec``:
python, official-docs, cpython, P0
Local_Trusted_Corpus
8a17438a-90f7-430c-bc36-07bae63bf2e5
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,302
supabase-export-v2
5edfbe4b376a0de3
`Typing cheat sheet <https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html>`_ A quick overview of type hints (hosted at the mypy docs) Type System Reference section of `the mypy docs <https://mypy.readthedocs.io/en/stable/index.html>`_ The Python typing system is standardised via PEPs, so this reference should b...
trusted_official_docs
CPython Docs
`Typing cheat sheet <https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html>`_ A quick overview of type hints (hosted at the mypy docs) Type System Reference section of `the mypy docs <https://mypy.readthedocs.io/en/stable/index.html>`_ The Python typing system is standardised via PEPs, so this reference should b...
`Typing cheat sheet <https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html>`_ A quick overview of type hints (hosted at the mypy docs) Type System Reference section of `the mypy docs <https://mypy.readthedocs.io/en/stable/index.html>`_ The Python typing system is standardised via PEPs, so this reference should b...
python, official-docs, cpython, P0
Local_Trusted_Corpus
8a33969f-5641-4922-9c7e-f4653e6d0c9f
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,746
supabase-export-v2
76a99d6a8ce2b64c
input and output types are incompatible (e.g., ``list[object]`` to ``list[int]``) or when the function does not return ``True`` for all instances of the narrowed type. Using ``-> TypeIs[NarrowedType]`` tells the static type checker that for a given function:
trusted_official_docs
CPython Docs
input and output types are incompatible (e.g., ``list[object]`` to ``list[int]``) or when the function does not return ``True`` for all instances of the narrowed type. Using ``-> TypeIs[NarrowedType]`` tells the static type checker that for a given function:
input and output types are incompatible (e.g., ``list[object]`` to ``list[int]``) or when the function does not return ``True`` for all instances of the narrowed type. Using ``-> TypeIs[NarrowedType]`` tells the static type checker that for a given function:
python, official-docs, cpython, P0
Local_Trusted_Corpus
8a5bcff5-9ff6-49d9-bbca-35a7d2512d85
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,733
supabase-export-v2
0d4a0e0b2b6639b8
A special form representing the value that results from evaluating a type expression. This value encodes the information supplied in the type expression, and it represents the type described by that type expression.
trusted_official_docs
CPython Docs
A special form representing the value that results from evaluating a type expression. This value encodes the information supplied in the type expression, and it represents the type described by that type expression.
A special form representing the value that results from evaluating a type expression. This value encodes the information supplied in the type expression, and it represents the type described by that type expression.
python, official-docs, cpython, P0
Local_Trusted_Corpus
8a86cef7-98bc-4946-bf67-febf0aefcee5
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,744
supabase-export-v2
61684959676e5cec
analyzing conditional code flow and applying the narrowing to a block of code. The conditional expression here is sometimes referred to as a "type predicate":: def is_str(val: str | float): # "isinstance" type predicate if isinstance(val, str): # Type of ``val`` is narrowed to ``str`` ... else: # Else, type of ``v...
trusted_official_docs
CPython Docs
analyzing conditional code flow and applying the narrowing to a block of code. The conditional expression here is sometimes referred to as a "type predicate":: def is_str(val: str | float): # "isinstance" type predicate if isinstance(val, str): # Type of ``val`` is narrowed to ``str`` ... else: # Else, type of ``v...
analyzing conditional code flow and applying the narrowing to a block of code. The conditional expression here is sometimes referred to as a "type predicate":: def is_str(val: str | float): # "isinstance" type predicate if isinstance(val, str): # Type of ``val`` is narrowed to ``str`` ... else: # Else, type of ``v...
python, official-docs, cpython, P0
Local_Trusted_Corpus
8ab4bbab-e785-4bdf-9a0a-3ec6724371e0
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,422
supabase-export-v2
b9b09071e8c28a6e
For use in type annotations, either use :class:`~collections.abc.Buffer` or a union that explicitly specifies the types your code supports (e.g., ``bytes | bytearray | memoryview``). :class:`!ByteString` was originally intended to be an abstract class that would serve as a supertype of both :class:`bytes` and :class:`...
trusted_official_docs
CPython Docs
For use in type annotations, either use :class:`~collections.abc.Buffer` or a union that explicitly specifies the types your code supports (e.g., ``bytes | bytearray | memoryview``). :class:`!ByteString` was originally intended to be an abstract class that would serve as a supertype of both :class:`bytes` and :class:`...
For use in type annotations, either use :class:`~collections.abc.Buffer` or a union that explicitly specifies the types your code supports (e.g., ``bytes | bytearray | memoryview``). :class:`!ByteString` was originally intended to be an abstract class that would serve as a supertype of both :class:`bytes` and :class:`...
python, official-docs, cpython, P0
Local_Trusted_Corpus
8bf7cae0-7869-4c5c-8a88-2c094184f24b
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,540
supabase-export-v2
929ba4918160392a
:class:`Any` type, nor does it mean "any string". In particular, ``AnyStr`` and ``str | bytes`` are different from each other and have different use cases:: # Invalid use of AnyStr: # The type variable is used only once in the function signature, # so cannot be "solved" by the type checker def greet_bad(cond: bool) ...
trusted_official_docs
CPython Docs
:class:`Any` type, nor does it mean "any string". In particular, ``AnyStr`` and ``str | bytes`` are different from each other and have different use cases:: # Invalid use of AnyStr: # The type variable is used only once in the function signature, # so cannot be "solved" by the type checker def greet_bad(cond: bool) ...
:class:`Any` type, nor does it mean "any string". In particular, ``AnyStr`` and ``str | bytes`` are different from each other and have different use cases:: # Invalid use of AnyStr: # The type variable is used only once in the function signature, # so cannot be "solved" by the type checker def greet_bad(cond: bool) ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
8caf5024-a6aa-43d0-9d4d-1f43be9eb352
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,004
supabase-export-v2
2cc82f47759d0e4c
field names are in the ``_fields`` attribute and the default values are in the ``_field_defaults`` attribute, both of which are part of the :func:`~collections.namedtuple` API.) ``NamedTuple`` subclasses can also have docstrings and methods::
trusted_official_docs
CPython Docs
field names are in the ``_fields`` attribute and the default values are in the ``_field_defaults`` attribute, both of which are part of the :func:`~collections.namedtuple` API.) ``NamedTuple`` subclasses can also have docstrings and methods::
field names are in the ``_fields`` attribute and the default values are in the ``_field_defaults`` attribute, both of which are part of the :func:`~collections.namedtuple` API.) ``NamedTuple`` subclasses can also have docstrings and methods::
python, official-docs, cpython, P0
Local_Trusted_Corpus
8d1ccad5-03da-46fd-b56d-7c33ca4f0991
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,703
supabase-export-v2
a1739404ab6d4fc5
tool consuming the annotations to decide whether the client is allowed to add multiple metadata elements to one annotation and how to merge those annotations. Nested ``Annotated`` types are flattened. The order of the metadata elements starts with the innermost annotation::
trusted_official_docs
CPython Docs
tool consuming the annotations to decide whether the client is allowed to add multiple metadata elements to one annotation and how to merge those annotations. Nested ``Annotated`` types are flattened. The order of the metadata elements starts with the innermost annotation::
tool consuming the annotations to decide whether the client is allowed to add multiple metadata elements to one annotation and how to merge those annotations. Nested ``Annotated`` types are flattened. The order of the metadata elements starts with the innermost annotation::
python, official-docs, cpython, P0
Local_Trusted_Corpus
8d987684-b026-4448-a3d8-97929d9b03af
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,983
supabase-export-v2
76d11d5ddfa83059
.. method:: evaluate_value An :term:`evaluate function` corresponding to the :attr:`__value__` attribute. When called directly, this method supports only the :attr:`~annotationlib.Format.VALUE` format, which is equivalent to accessing the :attr:`__value__` attribute directly, but the method object can be passed to :f...
trusted_official_docs
CPython Docs
.. method:: evaluate_value An :term:`evaluate function` corresponding to the :attr:`__value__` attribute. When called directly, this method supports only the :attr:`~annotationlib.Format.VALUE` format, which is equivalent to accessing the :attr:`__value__` attribute directly, but the method object can be passed to :f...
.. method:: evaluate_value An :term:`evaluate function` corresponding to the :attr:`__value__` attribute. When called directly, this method supports only the :attr:`~annotationlib.Format.VALUE` format, which is equivalent to accessing the :attr:`__value__` attribute directly, but the method object can be passed to :f...
python, official-docs, cpython, P0
Local_Trusted_Corpus
8dce31d5-1427-47e7-8d0f-2c5ae843c295
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,584
supabase-export-v2
0c4a75793afd0efa
Factors: TypeAlias = list[int] ``TypeAlias`` is particularly useful on older Python versions for annotating aliases that make use of forward references, as it can be hard for type checkers to distinguish these from normal variable assignments:
trusted_official_docs
CPython Docs
Factors: TypeAlias = list[int] ``TypeAlias`` is particularly useful on older Python versions for annotating aliases that make use of forward references, as it can be hard for type checkers to distinguish these from normal variable assignments:
Factors: TypeAlias = list[int] ``TypeAlias`` is particularly useful on older Python versions for annotating aliases that make use of forward references, as it can be hard for type checkers to distinguish these from normal variable assignments:
python, official-docs, cpython, P0
Local_Trusted_Corpus
8f0c0c37-2ce0-442f-be09-77f5ba1a18a3
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,902
supabase-export-v2
6519fccd35464147
.. method:: evaluate_default An :term:`evaluate function` corresponding to the :attr:`~TypeVarTuple.__default__` attribute. When called directly, this method supports only the :attr:`~annotationlib.Format.VALUE` format, which is equivalent to accessing the :attr:`~TypeVarTuple.__default__` attribute directly, but the...
trusted_official_docs
CPython Docs
.. method:: evaluate_default An :term:`evaluate function` corresponding to the :attr:`~TypeVarTuple.__default__` attribute. When called directly, this method supports only the :attr:`~annotationlib.Format.VALUE` format, which is equivalent to accessing the :attr:`~TypeVarTuple.__default__` attribute directly, but the...
.. method:: evaluate_default An :term:`evaluate function` corresponding to the :attr:`~TypeVarTuple.__default__` attribute. When called directly, this method supports only the :attr:`~annotationlib.Format.VALUE` format, which is equivalent to accessing the :attr:`~TypeVarTuple.__default__` attribute directly, but the...
python, official-docs, cpython, P0
Local_Trusted_Corpus
8ffdf30f-e5f2-4501-804e-d7f4ee7c6629
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,483
supabase-export-v2
1353b0ce1d6f148b
:mod:`!typing` module as a specialized type variable. The one exception to this is that a list of types can be used to substitute a :class:`ParamSpec`:: >>> class Z[T, **P]: ... # T is a TypeVar; P is a ParamSpec ... >>> Z[int, [dict, float]] __main__.Z[int, [dict, float]]
trusted_official_docs
CPython Docs
:mod:`!typing` module as a specialized type variable. The one exception to this is that a list of types can be used to substitute a :class:`ParamSpec`:: >>> class Z[T, **P]: ... # T is a TypeVar; P is a ParamSpec ... >>> Z[int, [dict, float]] __main__.Z[int, [dict, float]]
:mod:`!typing` module as a specialized type variable. The one exception to this is that a list of types can be used to substitute a :class:`ParamSpec`:: >>> class Z[T, **P]: ... # T is a TypeVar; P is a ParamSpec ... >>> Z[int, [dict, float]] __main__.Z[int, [dict, float]]
python, official-docs, cpython, P0
Local_Trusted_Corpus
90095d2a-df67-41db-9d11-1f5ba2fc6d40
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,640
supabase-export-v2
21feb84d498d3970
open_helper('/some/path', 'r') # Passes type check open_helper('/other/path', 'typo') # Error in type checker ``Literal[...]`` cannot be subclassed. At runtime, an arbitrary value is allowed as type argument to ``Literal[...]``, but type checkers may impose restrictions. See :pep:`586` for more details about literal ...
trusted_official_docs
CPython Docs
open_helper('/some/path', 'r') # Passes type check open_helper('/other/path', 'typo') # Error in type checker ``Literal[...]`` cannot be subclassed. At runtime, an arbitrary value is allowed as type argument to ``Literal[...]``, but type checkers may impose restrictions. See :pep:`586` for more details about literal ...
open_helper('/some/path', 'r') # Passes type check open_helper('/other/path', 'typo') # Error in type checker ``Literal[...]`` cannot be subclassed. At runtime, an arbitrary value is allowed as type argument to ``Literal[...]``, but type checkers may impose restrictions. See :pep:`586` for more details about literal ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
903b0415-3801-4744-98f2-2e7262c42323
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,578
supabase-export-v2
eee7c01aa4910694
not use ``Self`` as the return annotation if the method is not guaranteed to return an instance of a subclass when the class is subclassed:: class Eggs: # Self would be an incorrect return annotation here, # as the object returned is always an instance of Eggs, # even in subclasses def returns_eggs(self) -> "Eggs":...
trusted_official_docs
CPython Docs
not use ``Self`` as the return annotation if the method is not guaranteed to return an instance of a subclass when the class is subclassed:: class Eggs: # Self would be an incorrect return annotation here, # as the object returned is always an instance of Eggs, # even in subclasses def returns_eggs(self) -> "Eggs":...
not use ``Self`` as the return annotation if the method is not guaranteed to return an instance of a subclass when the class is subclassed:: class Eggs: # Self would be an incorrect return annotation here, # as the object returned is always an instance of Eggs, # even in subclasses def returns_eggs(self) -> "Eggs":...
python, official-docs, cpython, P0
Local_Trusted_Corpus
9067e983-4d84-47b0-b018-8e8d12c4c805
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,521
supabase-export-v2
88b1bb58c05bd224
def collect(items: Iterable[int]) -> int: ... result = collect(Bucket()) # Passes type check Moreover, by subclassing a special class :class:`Protocol`, a user can define new custom protocols to fully enjoy structural subtyping (see examples below).
trusted_official_docs
CPython Docs
def collect(items: Iterable[int]) -> int: ... result = collect(Bucket()) # Passes type check Moreover, by subclassing a special class :class:`Protocol`, a user can define new custom protocols to fully enjoy structural subtyping (see examples below).
def collect(items: Iterable[int]) -> int: ... result = collect(Bucket()) # Passes type check Moreover, by subclassing a special class :class:`Protocol`, a user can define new custom protocols to fully enjoy structural subtyping (see examples below).
python, official-docs, cpython, P0
Local_Trusted_Corpus
91a682fa-7361-44a5-a19e-a42446166b88
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,985
supabase-export-v2
986de3a97526d8fd
.. doctest:: >>> type Alias = undefined >>> Alias.__value__ Traceback (most recent call last): ... NameError: name 'undefined' is not defined >>> from annotationlib import Format, call_evaluate_function >>> Alias.evaluate_value(Format.VALUE) Traceback (most recent call last): ... NameError: name 'undefined' is n...
trusted_official_docs
CPython Docs
.. doctest:: >>> type Alias = undefined >>> Alias.__value__ Traceback (most recent call last): ... NameError: name 'undefined' is not defined >>> from annotationlib import Format, call_evaluate_function >>> Alias.evaluate_value(Format.VALUE) Traceback (most recent call last): ... NameError: name 'undefined' is n...
.. doctest:: >>> type Alias = undefined >>> Alias.__value__ Traceback (most recent call last): ... NameError: name 'undefined' is not defined >>> from annotationlib import Format, call_evaluate_function >>> Alias.evaluate_value(Format.VALUE) Traceback (most recent call last): ... NameError: name 'undefined' is n...
python, official-docs, cpython, P0
Local_Trusted_Corpus
9663af2c-b788-407a-8285-007ffe9b1307
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,270
supabase-export-v2
d41d9f32333c7090
Users may also mark other classes as disjoint bases to indicate to type checkers that multiple inheritance with other disjoint bases should not be allowed. Note that the concept of a solid base is a CPython implementation detail, and the exact set of standard library classes that are disjoint bases at runtime may cha...
trusted_official_docs
CPython Docs
Users may also mark other classes as disjoint bases to indicate to type checkers that multiple inheritance with other disjoint bases should not be allowed. Note that the concept of a solid base is a CPython implementation detail, and the exact set of standard library classes that are disjoint bases at runtime may cha...
Users may also mark other classes as disjoint bases to indicate to type checkers that multiple inheritance with other disjoint bases should not be allowed. Note that the concept of a solid base is a CPython implementation detail, and the exact set of standard library classes that are disjoint bases at runtime may cha...
python, official-docs, cpython, P0
Local_Trusted_Corpus
968cf144-10e5-4ace-8c93-b65cfb551ac3
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,492
supabase-export-v2
33322b15c6fc35e2
.. versionchanged:: 3.10 :class:`Generic` can now be parameterized over parameter expressions. See :class:`ParamSpec` and :pep:`612` for more details. A user-defined generic class can have ABCs as base classes without a metaclass conflict. Generic metaclasses are not supported. The outcome of parameterizing generics is...
trusted_official_docs
CPython Docs
.. versionchanged:: 3.10 :class:`Generic` can now be parameterized over parameter expressions. See :class:`ParamSpec` and :pep:`612` for more details. A user-defined generic class can have ABCs as base classes without a metaclass conflict. Generic metaclasses are not supported. The outcome of parameterizing generics is...
.. versionchanged:: 3.10 :class:`Generic` can now be parameterized over parameter expressions. See :class:`ParamSpec` and :pep:`612` for more details. A user-defined generic class can have ABCs as base classes without a metaclass conflict. Generic metaclasses are not supported. The outcome of parameterizing generics is...
python, official-docs, cpython, P0
Local_Trusted_Corpus
973d83d1-4095-40fb-a041-25fc66a5c890
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,802
supabase-export-v2
bf6dfae6be9a7f80
This syntax can also be used to create bounded and constrained type variables:: class StrSequence[S: str]: # S is a TypeVar with a `str` upper bound; ... # we can say that S is "bounded by `str`"
trusted_official_docs
CPython Docs
This syntax can also be used to create bounded and constrained type variables:: class StrSequence[S: str]: # S is a TypeVar with a `str` upper bound; ... # we can say that S is "bounded by `str`"
This syntax can also be used to create bounded and constrained type variables:: class StrSequence[S: str]: # S is a TypeVar with a `str` upper bound; ... # we can say that S is "bounded by `str`"
python, official-docs, cpython, P0
Local_Trusted_Corpus
97ed3f1f-d7bc-48a3-a93a-41210a4cf8f5
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,767
supabase-export-v2
cd214721975cdbd9
``TypeIs`` and ``TypeGuard`` differ in the following ways: * ``TypeIs`` requires the narrowed type to be a subtype of the input type, while ``TypeGuard`` does not. The main reason is to allow for things like narrowing ``list[object]`` to ``list[str]`` even though the latter is not a subtype of the former, since ``li...
trusted_official_docs
CPython Docs
``TypeIs`` and ``TypeGuard`` differ in the following ways: * ``TypeIs`` requires the narrowed type to be a subtype of the input type, while ``TypeGuard`` does not. The main reason is to allow for things like narrowing ``list[object]`` to ``list[str]`` even though the latter is not a subtype of the former, since ``li...
``TypeIs`` and ``TypeGuard`` differ in the following ways: * ``TypeIs`` requires the narrowed type to be a subtype of the input type, while ``TypeGuard`` does not. The main reason is to allow for things like narrowing ``list[object]`` to ``list[str]`` even though the latter is not a subtype of the former, since ``li...
python, official-docs, cpython, P0
Local_Trusted_Corpus
983b42b9-9398-4a54-b1e5-935f0f1a15bf
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,110
supabase-export-v2
ef5136df543fee6d
typing import TypedDict >>> class Point2D(TypedDict): pass >>> Point2D.__total__ True >>> class Point2D(TypedDict, total=False): pass >>> Point2D.__total__ False >>> class Point3D(Point2D): pass >>> Point3D.__total__ True This attribute reflects *only* the value of the ``total`` argument to the current ``TypedDict`` c...
trusted_official_docs
CPython Docs
typing import TypedDict >>> class Point2D(TypedDict): pass >>> Point2D.__total__ True >>> class Point2D(TypedDict, total=False): pass >>> Point2D.__total__ False >>> class Point3D(Point2D): pass >>> Point3D.__total__ True This attribute reflects *only* the value of the ``total`` argument to the current ``TypedDict`` c...
typing import TypedDict >>> class Point2D(TypedDict): pass >>> Point2D.__total__ True >>> class Point2D(TypedDict, total=False): pass >>> Point2D.__total__ False >>> class Point3D(Point2D): pass >>> Point3D.__total__ True This attribute reflects *only* the value of the ``total`` argument to the current ``TypedDict`` c...
python, official-docs, cpython, P0
Local_Trusted_Corpus
98407d9d-1db9-4635-9957-4dbd6314f3db
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,979
supabase-export-v2
9433bb28eaf9334f
.. attribute:: __value__ The type alias's value. This is :ref:`lazily evaluated <lazy-evaluation>`, so names used in the definition of the alias are not resolved until the ``__value__`` attribute is accessed:
trusted_official_docs
CPython Docs
.. attribute:: __value__ The type alias's value. This is :ref:`lazily evaluated <lazy-evaluation>`, so names used in the definition of the alias are not resolved until the ``__value__`` attribute is accessed:
.. attribute:: __value__ The type alias's value. This is :ref:`lazily evaluated <lazy-evaluation>`, so names used in the definition of the alias are not resolved until the ``__value__`` attribute is accessed:
python, official-docs, cpython, P0
Local_Trusted_Corpus
9954c99f-775a-4ca1-90fa-1873bd52e658
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,083
supabase-export-v2
ed8e7eefc834e0a0
This means that a ``Point2D`` ``TypedDict`` can have the ``label`` key omitted. It is also possible to mark all keys as non-required by default by specifying a totality of ``False``::
trusted_official_docs
CPython Docs
This means that a ``Point2D`` ``TypedDict`` can have the ``label`` key omitted. It is also possible to mark all keys as non-required by default by specifying a totality of ``False``::
This means that a ``Point2D`` ``TypedDict`` can have the ``label`` key omitted. It is also possible to mark all keys as non-required by default by specifying a totality of ``False``::
python, official-docs, cpython, P0
Local_Trusted_Corpus
9971fd1d-07fe-47e4-ba57-204215198025
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,163
supabase-export-v2
418e65c00e37e3d8
that the return value has the designated type, but at runtime we intentionally don't check anything (we want this to be as fast as possible). .. function:: assert_type(val, typ, /)
trusted_official_docs
CPython Docs
that the return value has the designated type, but at runtime we intentionally don't check anything (we want this to be as fast as possible). .. function:: assert_type(val, typ, /)
that the return value has the designated type, but at runtime we intentionally don't check anything (we want this to be as fast as possible). .. function:: assert_type(val, typ, /)
python, official-docs, cpython, P0
Local_Trusted_Corpus
99cd0ec8-882a-4146-a79f-053c9c8a869f
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,363
supabase-export-v2
ffec62e508d2d4e1
x: Callable[..., str] x = str # OK x = concat # Also OK ``Callable`` cannot express complex signatures such as functions that take a variadic number of arguments, :ref:`overloaded functions <overload>`, or functions that have keyword-only parameters. However, these signatures can be expressed by defining a :class:`Prot...
trusted_official_docs
CPython Docs
x: Callable[..., str] x = str # OK x = concat # Also OK ``Callable`` cannot express complex signatures such as functions that take a variadic number of arguments, :ref:`overloaded functions <overload>`, or functions that have keyword-only parameters. However, these signatures can be expressed by defining a :class:`Prot...
x: Callable[..., str] x = str # OK x = concat # Also OK ``Callable`` cannot express complex signatures such as functions that take a variadic number of arguments, :ref:`overloaded functions <overload>`, or functions that have keyword-only parameters. However, these signatures can be expressed by defining a :class:`Prot...
python, official-docs, cpython, P0
Local_Trusted_Corpus
99ced062-8db3-43b6-9842-2366efdd6888
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,343
supabase-export-v2
b60aa08a32e1997e
.. note:: Recall that the use of a type alias declares two types to be *equivalent* to one another. Doing ``type Alias = Original`` will make the static type checker treat ``Alias`` as being *exactly equivalent* to ``Original`` in all cases. This is useful when you want to simplify complex type signatures.
trusted_official_docs
CPython Docs
.. note:: Recall that the use of a type alias declares two types to be *equivalent* to one another. Doing ``type Alias = Original`` will make the static type checker treat ``Alias`` as being *exactly equivalent* to ``Original`` in all cases. This is useful when you want to simplify complex type signatures.
.. note:: Recall that the use of a type alias declares two types to be *equivalent* to one another. Doing ``type Alias = Original`` will make the static type checker treat ``Alias`` as being *exactly equivalent* to ``Original`` in all cases. This is useful when you want to simplify complex type signatures.
python, official-docs, cpython, P0
Local_Trusted_Corpus
9a438418-6342-4387-bbf3-6ddb2fcef472
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,303
supabase-export-v2
7e96f0af12cfb741
typing system is standardised via PEPs, so this reference should broadly apply to most Python type checkers. (Some parts may still be specific to mypy.) `Static Typing with Python <https://typing.python.org/en/latest/>`_ Type-checker-agnostic documentation written by the community detailing type system features, usef...
trusted_official_docs
CPython Docs
typing system is standardised via PEPs, so this reference should broadly apply to most Python type checkers. (Some parts may still be specific to mypy.) `Static Typing with Python <https://typing.python.org/en/latest/>`_ Type-checker-agnostic documentation written by the community detailing type system features, usef...
typing system is standardised via PEPs, so this reference should broadly apply to most Python type checkers. (Some parts may still be specific to mypy.) `Static Typing with Python <https://typing.python.org/en/latest/>`_ Type-checker-agnostic documentation written by the community detailing type system features, usef...
python, official-docs, cpython, P0
Local_Trusted_Corpus
9c7e4e21-5679-458e-962f-68b747c3d07a
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,065
supabase-export-v2
da0d311426f9f616
may no longer be considered instances of that protocol on Python 3.12+, and vice versa. Most users are unlikely to be affected by this change. .. versionchanged:: 3.12 The members of a runtime-checkable protocol are now considered "frozen" at runtime as soon as the class has been created. Monkey-patching attributes ...
trusted_official_docs
CPython Docs
may no longer be considered instances of that protocol on Python 3.12+, and vice versa. Most users are unlikely to be affected by this change. .. versionchanged:: 3.12 The members of a runtime-checkable protocol are now considered "frozen" at runtime as soon as the class has been created. Monkey-patching attributes ...
may no longer be considered instances of that protocol on Python 3.12+, and vice versa. Most users are unlikely to be affected by this change. .. versionchanged:: 3.12 The members of a runtime-checkable protocol are now considered "frozen" at runtime as soon as the class has been created. Monkey-patching attributes ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
9eb6f077-d839-4351-ba97-4dca82fad537
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,076
supabase-export-v2
e5cfba8b90e28531
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 names:: # raises SyntaxError class Point2D(TypedDict): in: int # 'in' is a keyword x-y: int # name with hyphens
trusted_official_docs
CPython Docs
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 names:: # raises SyntaxError class Point2D(TypedDict): in: int # 'in' is a keyword x-y: int # name with hyphens
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 names:: # raises SyntaxError class Point2D(TypedDict): in: int # 'in' is a keyword x-y: int # name with hyphens
python, official-docs, cpython, P0
Local_Trusted_Corpus
9eee4c69-1031-46f8-b8c2-76d460923010
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,344
supabase-export-v2
665044f040e1707e
static type checker treat ``Alias`` as being *exactly equivalent* to ``Original`` in all cases. This is useful when you want to simplify complex type signatures. In contrast, ``NewType`` declares one type to be a *subtype* of another. Doing ``Derived = NewType('Derived', Original)`` will make the static type checker t...
trusted_official_docs
CPython Docs
static type checker treat ``Alias`` as being *exactly equivalent* to ``Original`` in all cases. This is useful when you want to simplify complex type signatures. In contrast, ``NewType`` declares one type to be a *subtype* of another. Doing ``Derived = NewType('Derived', Original)`` will make the static type checker t...
static type checker treat ``Alias`` as being *exactly equivalent* to ``Original`` in all cases. This is useful when you want to simplify complex type signatures. In contrast, ``NewType`` declares one type to be a *subtype* of another. Doing ``Derived = NewType('Derived', Original)`` will make the static type checker t...
python, official-docs, cpython, P0
Local_Trusted_Corpus
9f5ca8fe-6e5f-4473-add4-79cebf887988
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,298
supabase-export-v2
1d951a0c59045326
as indicated by the :term:`type hint` ``edge_length: float``. The function is expected to return an instance of :class:`str`, as indicated by the ``-> str`` hint. While type hints can be simple classes like :class:`float` or :class:`str`, they can also be more complex. The :mod:`typing` module provides a vocabulary of ...
trusted_official_docs
CPython Docs
as indicated by the :term:`type hint` ``edge_length: float``. The function is expected to return an instance of :class:`str`, as indicated by the ``-> str`` hint. While type hints can be simple classes like :class:`float` or :class:`str`, they can also be more complex. The :mod:`typing` module provides a vocabulary of ...
as indicated by the :term:`type hint` ``edge_length: float``. The function is expected to return an instance of :class:`str`, as indicated by the ``-> str`` hint. While type hints can be simple classes like :class:`float` or :class:`str`, they can also be more complex. The :mod:`typing` module provides a vocabulary of ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
9f9a7a1f-a339-4d9f-93ac-317a1aaaabd1
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,768
supabase-export-v2
f7ed385cc0cef7a0
this is known as an intersection type.) * When a ``TypeGuard`` function returns ``False``, type checkers cannot narrow the type of the variable at all. When a ``TypeIs`` function returns ``False``, type checkers can narrow the type of the variable to exclude the ``TypeIs`` type.
trusted_official_docs
CPython Docs
this is known as an intersection type.) * When a ``TypeGuard`` function returns ``False``, type checkers cannot narrow the type of the variable at all. When a ``TypeIs`` function returns ``False``, type checkers can narrow the type of the variable to exclude the ``TypeIs`` type.
this is known as an intersection type.) * When a ``TypeGuard`` function returns ``False``, type checkers cannot narrow the type of the variable at all. When a ``TypeIs`` function returns ``False``, type checkers can narrow the type of the variable to exclude the ``TypeIs`` type.
python, official-docs, cpython, P0
Local_Trusted_Corpus
9fb997e8-468e-4e12-879a-400892191713
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,249
supabase-export-v2
671477b5d869c563
class (but not to methods defined in its superclasses or subclasses). Type checkers will ignore all annotations in a function or class with this decorator. ``@no_type_check`` mutates the decorated object in place.
trusted_official_docs
CPython Docs
class (but not to methods defined in its superclasses or subclasses). Type checkers will ignore all annotations in a function or class with this decorator. ``@no_type_check`` mutates the decorated object in place.
class (but not to methods defined in its superclasses or subclasses). Type checkers will ignore all annotations in a function or class with this decorator. ``@no_type_check`` mutates the decorated object in place.
python, official-docs, cpython, P0
Local_Trusted_Corpus
a0916500-17e4-45a7-9086-0381b28e0aad
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,309
supabase-export-v2
ca5a008742b297e9
>>> from typing import Protocol, get_protocol_members >>> class P(Protocol): ... def a(self) -> str: ... ... b: int >>> get_protocol_members(P) == frozenset({'a', 'b'}) True Raise :exc:`TypeError` for arguments that are not Protocols.
trusted_official_docs
CPython Docs
>>> from typing import Protocol, get_protocol_members >>> class P(Protocol): ... def a(self) -> str: ... ... b: int >>> get_protocol_members(P) == frozenset({'a', 'b'}) True Raise :exc:`TypeError` for arguments that are not Protocols.
>>> from typing import Protocol, get_protocol_members >>> class P(Protocol): ... def a(self) -> str: ... ... b: int >>> get_protocol_members(P) == frozenset({'a', 'b'}) True Raise :exc:`TypeError` for arguments that are not Protocols.
python, official-docs, cpython, P0
Local_Trusted_Corpus
a0f14715-4980-4628-b1ec-aee2626389f3
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,428
supabase-export-v2
b3428863d2ee6956
a similar fashion, but don't expect a ``ReturnType`` type argument (:class:`AsyncGenerator[YieldType, SendType] <collections.abc.AsyncGenerator>`). The ``SendType`` argument defaults to :const:`!None`, so the following definitions are equivalent:: async def infinite_stream(start: int) -> AsyncGenerator[int]: while Tru...
trusted_official_docs
CPython Docs
a similar fashion, but don't expect a ``ReturnType`` type argument (:class:`AsyncGenerator[YieldType, SendType] <collections.abc.AsyncGenerator>`). The ``SendType`` argument defaults to :const:`!None`, so the following definitions are equivalent:: async def infinite_stream(start: int) -> AsyncGenerator[int]: while Tru...
a similar fashion, but don't expect a ``ReturnType`` type argument (:class:`AsyncGenerator[YieldType, SendType] <collections.abc.AsyncGenerator>`). The ``SendType`` argument defaults to :const:`!None`, so the following definitions are equivalent:: async def infinite_stream(start: int) -> AsyncGenerator[int]: while Tru...
python, official-docs, cpython, P0
Local_Trusted_Corpus
a1a2a6a0-0dbd-4159-aa4a-b98967c01129
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,921
supabase-export-v2
93f356e5718185e1
parameter specification variable tells the type checker that the callable passed into the decorator and the new callable returned by it have inter-dependent type parameters:: from collections.abc import Callable import logging
trusted_official_docs
CPython Docs
parameter specification variable tells the type checker that the callable passed into the decorator and the new callable returned by it have inter-dependent type parameters:: from collections.abc import Callable import logging
parameter specification variable tells the type checker that the callable passed into the decorator and the new callable returned by it have inter-dependent type parameters:: from collections.abc import Callable import logging
python, official-docs, cpython, P0
Local_Trusted_Corpus
a2268b36-3034-4665-9999-2862b559ccbe
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,217
supabase-export-v2
9da1f4ccf33f24be
``kw_only`` - Indicates whether the field should be marked as keyword-only. If ``True``, the field will be keyword-only. If ``False``, it will not be keyword-only. If unspecified, the value of the ``kw_only`` parameter on the object decorated with ``dataclass_transform`` will be used, or if that is unspecified, the ...
trusted_official_docs
CPython Docs
``kw_only`` - Indicates whether the field should be marked as keyword-only. If ``True``, the field will be keyword-only. If ``False``, it will not be keyword-only. If unspecified, the value of the ``kw_only`` parameter on the object decorated with ``dataclass_transform`` will be used, or if that is unspecified, the ...
``kw_only`` - Indicates whether the field should be marked as keyword-only. If ``True``, the field will be keyword-only. If ``False``, it will not be keyword-only. If unspecified, the value of the ``kw_only`` parameter on the object decorated with ``dataclass_transform`` will be used, or if that is unspecified, the ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
a2900a36-5216-45ae-a4c5-ec47353b4a24
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,350
supabase-export-v2
62d27b66a2021000
Annotating callable objects =========================== Functions -- or other :term:`callable` objects -- can be annotated using :class:`collections.abc.Callable` or deprecated :data:`typing.Callable`. ``Callable[[int], str]`` signifies a function that takes a single parameter of type :class:`int` and returns a :class:...
trusted_official_docs
CPython Docs
Annotating callable objects =========================== Functions -- or other :term:`callable` objects -- can be annotated using :class:`collections.abc.Callable` or deprecated :data:`typing.Callable`. ``Callable[[int], str]`` signifies a function that takes a single parameter of type :class:`int` and returns a :class:...
Annotating callable objects =========================== Functions -- or other :term:`callable` objects -- can be annotated using :class:`collections.abc.Callable` or deprecated :data:`typing.Callable`. ``Callable[[int], str]`` signifies a function that takes a single parameter of type :class:`int` and returns a :class:...
python, official-docs, cpython, P0
Local_Trusted_Corpus
a2ceecf4-b6b0-48ca-9bdd-dc1cbc480e02
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,484
supabase-export-v2
3aefb018528518ec
>>> class Z[T, **P]: ... # T is a TypeVar; P is a ParamSpec ... >>> Z[int, [dict, float]] __main__.Z[int, [dict, float]] Classes generic over a :class:`ParamSpec` can also be created using explicit inheritance from :class:`Generic`. In this case, ``**`` is not used::
trusted_official_docs
CPython Docs
>>> class Z[T, **P]: ... # T is a TypeVar; P is a ParamSpec ... >>> Z[int, [dict, float]] __main__.Z[int, [dict, float]] Classes generic over a :class:`ParamSpec` can also be created using explicit inheritance from :class:`Generic`. In this case, ``**`` is not used::
>>> class Z[T, **P]: ... # T is a TypeVar; P is a ParamSpec ... >>> Z[int, [dict, float]] __main__.Z[int, [dict, float]] Classes generic over a :class:`ParamSpec` can also be created using explicit inheritance from :class:`Generic`. In this case, ``**`` is not used::
python, official-docs, cpython, P0
Local_Trusted_Corpus
a4e82739-b2ae-4b3c-aefe-4e5643578e8f
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
31,292
supabase-export-v2
550c30872089670a
3.11 Previously, ``Optional[t]`` was added for function and method annotations if a default value equal to ``None`` was set. Now the annotation is returned unchanged. .. versionchanged:: 3.14 Added the ``format`` parameter. See the documentation on :func:`annotationlib.get_annotations` for more information.
trusted_official_docs
CPython Docs
3.11 Previously, ``Optional[t]`` was added for function and method annotations if a default value equal to ``None`` was set. Now the annotation is returned unchanged. .. versionchanged:: 3.14 Added the ``format`` parameter. See the documentation on :func:`annotationlib.get_annotations` for more information.
3.11 Previously, ``Optional[t]`` was added for function and method annotations if a default value equal to ``None`` was set. Now the annotation is returned unchanged. .. versionchanged:: 3.14 Added the ``format`` parameter. See the documentation on :func:`annotationlib.get_annotations` for more information.
python, official-docs, cpython, P0
Local_Trusted_Corpus
a779671c-ae17-4ce2-93d5-667761b1c9d8
CPython Docs
file://datasets/cpython/Doc/library/typing.rst
unknown
761dcd07-e75b-4e99-a2c4-881ccac2b544
30,419
supabase-export-v2
78572d0125c0d959
A generator can be annotated using the generic type :class:`Generator[YieldType, SendType, ReturnType] <collections.abc.Generator>`. For example:: def echo_round() -> Generator[int, float, str]: sent = yield 0 while sent >= 0: sent = yield round(sent) return 'Done'
trusted_official_docs
CPython Docs
A generator can be annotated using the generic type :class:`Generator[YieldType, SendType, ReturnType] <collections.abc.Generator>`. For example:: def echo_round() -> Generator[int, float, str]: sent = yield 0 while sent >= 0: sent = yield round(sent) return 'Done'
A generator can be annotated using the generic type :class:`Generator[YieldType, SendType, ReturnType] <collections.abc.Generator>`. For example:: def echo_round() -> Generator[int, float, str]: sent = yield 0 while sent >= 0: sent = yield round(sent) return 'Done'
python, official-docs, cpython, P0
Local_Trusted_Corpus