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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f00b17cd-1b87-4061-aca5-79ef9a9a2c07 | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 31,116 | supabase-export-v2 | 4fdbf21f0ba02eb2 | Keys marked with :data:`Required` will always appear in ``__required_keys__`` and keys marked with :data:`NotRequired` will always appear in ``__optional_keys__``.
For backwards compatibility with Python 3.10 and below,
it is also possible to use inheritance to declare both required and
non-required keys in the same ... | trusted_official_docs | CPython Docs | Keys marked with :data:`Required` will always appear in ``__required_keys__`` and keys marked with :data:`NotRequired` will always appear in ``__optional_keys__``.
For backwards compatibility with Python 3.10 and below,
it is also possible to use inheritance to declare both required and
non-required keys in the same ... | Keys marked with :data:`Required` will always appear in ``__required_keys__`` and keys marked with :data:`NotRequired` will always appear in ``__optional_keys__``.
For backwards compatibility with Python 3.10 and below,
it is also possible to use inheritance to declare both required and
non-required keys in the same ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f0420bdb-6cd5-4e24-ba12-918898bd9eb5 | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 30,660 | supabase-export-v2 | f1eb00a37df20961 | :data:`ClassVar` accepts only types and cannot be further subscribed.
:data:`ClassVar` is not a class itself, and should not
be used with :func:`isinstance` or :func:`issubclass`. :data:`ClassVar` does not change Python runtime behavior, but
it can be used by third-party type checkers. For example, a type checker
mi... | trusted_official_docs | CPython Docs | :data:`ClassVar` accepts only types and cannot be further subscribed.
:data:`ClassVar` is not a class itself, and should not
be used with :func:`isinstance` or :func:`issubclass`. :data:`ClassVar` does not change Python runtime behavior, but
it can be used by third-party type checkers. For example, a type checker
mi... | :data:`ClassVar` accepts only types and cannot be further subscribed.
:data:`ClassVar` is not a class itself, and should not
be used with :func:`isinstance` or :func:`issubclass`. :data:`ClassVar` does not change Python runtime behavior, but
it can be used by third-party type checkers. For example, a type checker
mi... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f097ce82-3742-443c-bdba-c786370ffebb | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 30,661 | supabase-export-v2 | 2b24fee5e32f1513 | Python runtime behavior, but it can be used by third-party type checkers. For example, a type checker might flag the following code as an error::
enterprise_d = Starship(3000)
enterprise_d.stats = {} # Error, setting class variable on instance
Starship.stats = {} # This is OK | trusted_official_docs | CPython Docs | Python runtime behavior, but it can be used by third-party type checkers. For example, a type checker might flag the following code as an error::
enterprise_d = Starship(3000)
enterprise_d.stats = {} # Error, setting class variable on instance
Starship.stats = {} # This is OK | Python runtime behavior, but it can be used by third-party type checkers. For example, a type checker might flag the following code as an error::
enterprise_d = Starship(3000)
enterprise_d.stats = {} # Error, setting class variable on instance
Starship.stats = {} # This is OK | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f0f20216-7e69-4f7c-b30f-71983befd0f7 | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 30,806 | supabase-export-v2 | 1e5f16aa18a42c03 | be anything S = TypeVar('S', bound=str) # Can be any subtype of str A = TypeVar('A', str, bytes) # Must be exactly str or bytes
Type variables exist primarily for the benefit of static type
checkers. They serve as the parameters for generic types as well
as for generic function and type alias definitions. See :class:... | trusted_official_docs | CPython Docs | be anything S = TypeVar('S', bound=str) # Can be any subtype of str A = TypeVar('A', str, bytes) # Must be exactly str or bytes
Type variables exist primarily for the benefit of static type
checkers. They serve as the parameters for generic types as well
as for generic function and type alias definitions. See :class:... | be anything S = TypeVar('S', bound=str) # Can be any subtype of str A = TypeVar('A', str, bytes) # Must be exactly str or bytes
Type variables exist primarily for the benefit of static type
checkers. They serve as the parameters for generic types as well
as for generic function and type alias definitions. See :class:... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f14230f9-4f0a-4a0b-961a-cd85cb577f10 | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 31,069 | supabase-export-v2 | b9405229c324e291 | Special construct to add type hints to a dictionary. At runtime ":class:`!TypedDict` instances" are simply :class:`dicts <dict>`.
``TypedDict`` declares a dictionary type that expects all of its
instances to have a certain set of keys, where each key is
associated with a value of a consistent type. This expectation
... | trusted_official_docs | CPython Docs | Special construct to add type hints to a dictionary. At runtime ":class:`!TypedDict` instances" are simply :class:`dicts <dict>`.
``TypedDict`` declares a dictionary type that expects all of its
instances to have a certain set of keys, where each key is
associated with a value of a consistent type. This expectation
... | Special construct to add type hints to a dictionary. At runtime ":class:`!TypedDict` instances" are simply :class:`dicts <dict>`.
``TypedDict`` declares a dictionary type that expects all of its
instances to have a certain set of keys, where each key is
associated with a value of a consistent type. This expectation
... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f20963fb-71d1-49e8-8cb6-7b4f45ed8557 | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 30,420 | supabase-export-v2 | 31d2c44340e47008 | def echo_round() -> Generator[int, float, str]: sent = yield 0 while sent >= 0: sent = yield round(sent) return 'Done'
Note that unlike many other generic classes in the standard library,
the ``SendType`` of :class:`~collections.abc.Generator` behaves
contravariantly, not covariantly or invariantly. | trusted_official_docs | CPython Docs | def echo_round() -> Generator[int, float, str]: sent = yield 0 while sent >= 0: sent = yield round(sent) return 'Done'
Note that unlike many other generic classes in the standard library,
the ``SendType`` of :class:`~collections.abc.Generator` behaves
contravariantly, not covariantly or invariantly. | def echo_round() -> Generator[int, float, str]: sent = yield 0 while sent >= 0: sent = yield round(sent) return 'Done'
Note that unlike many other generic classes in the standard library,
the ``SendType`` of :class:`~collections.abc.Generator` behaves
contravariantly, not covariantly or invariantly. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f3a00368-4d3f-40bb-bdce-ba0f0e53cdbc | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 30,752 | supabase-export-v2 | b976997ee3611525 | def is_parent(val: object) -> TypeIs[Parent]: return isinstance(val, Parent)
def run(arg: Child | Unrelated):
if is_parent(arg):
# Type of ``arg`` is narrowed to the intersection
# of ``Parent`` and ``Child``, which is equivalent to
# ``Child``. assert_type(arg, Child)
else:
# Type of ``arg`` is narrowed to exclu... | trusted_official_docs | CPython Docs | def is_parent(val: object) -> TypeIs[Parent]: return isinstance(val, Parent)
def run(arg: Child | Unrelated):
if is_parent(arg):
# Type of ``arg`` is narrowed to the intersection
# of ``Parent`` and ``Child``, which is equivalent to
# ``Child``. assert_type(arg, Child)
else:
# Type of ``arg`` is narrowed to exclu... | def is_parent(val: object) -> TypeIs[Parent]: return isinstance(val, Parent)
def run(arg: Child | Unrelated):
if is_parent(arg):
# Type of ``arg`` is narrowed to the intersection
# of ``Parent`` and ``Child``, which is equivalent to
# ``Child``. assert_type(arg, Child)
else:
# Type of ``arg`` is narrowed to exclu... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f3cae648-4828-4e99-b12a-792bedc49fef | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 31,121 | supabase-export-v2 | 6d99c8cede70e157 | is defined. Therefore, the runtime introspection that ``__required_keys__`` and ``__optional_keys__`` rely on may not work properly, and the values of the attributes may be incorrect.
Support for :data:`ReadOnly` is reflected in the following attributes: | trusted_official_docs | CPython Docs | is defined. Therefore, the runtime introspection that ``__required_keys__`` and ``__optional_keys__`` rely on may not work properly, and the values of the attributes may be incorrect.
Support for :data:`ReadOnly` is reflected in the following attributes: | is defined. Therefore, the runtime introspection that ``__required_keys__`` and ``__optional_keys__`` rely on may not work properly, and the values of the attributes may be incorrect.
Support for :data:`ReadOnly` is reflected in the following attributes: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f3de3258-27f1-4ae3-906a-b13fc9de1000 | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 30,400 | supabase-export-v2 | e55df8eff328c451 | .. index:: single: ...; ellipsis literal
To denote a tuple which could be of *any* length, and in which all elements are
of the same type ``T``, use the literal ellipsis ``...``: ``tuple[T, ...]``. To denote an empty tuple, use
``tuple[()]``. Using plain ``tuple`` as an annotation is equivalent to using
``tuple[Any, ..... | trusted_official_docs | CPython Docs | .. index:: single: ...; ellipsis literal
To denote a tuple which could be of *any* length, and in which all elements are
of the same type ``T``, use the literal ellipsis ``...``: ``tuple[T, ...]``. To denote an empty tuple, use
``tuple[()]``. Using plain ``tuple`` as an annotation is equivalent to using
``tuple[Any, ..... | .. index:: single: ...; ellipsis literal
To denote a tuple which could be of *any* length, and in which all elements are
of the same type ``T``, use the literal ellipsis ``...``: ``tuple[T, ...]``. To denote an empty tuple, use
``tuple[()]``. Using plain ``tuple`` as an annotation is equivalent to using
``tuple[Any, ..... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f40ac212-a3f6-4c0d-820e-61236b775fe0 | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 31,405 | supabase-export-v2 | 7ccc066a8b115701 | Deprecated aliases corresponding to the return types from :func:`re.compile` and :func:`re.search`.
These types (and the corresponding functions) are generic over
:data:`AnyStr`. ``Pattern`` can be specialised as ``Pattern[str]`` or
``Pattern[bytes]``; ``Match`` can be specialised as ``Match[str]`` or
``Match[bytes]... | trusted_official_docs | CPython Docs | Deprecated aliases corresponding to the return types from :func:`re.compile` and :func:`re.search`.
These types (and the corresponding functions) are generic over
:data:`AnyStr`. ``Pattern`` can be specialised as ``Pattern[str]`` or
``Pattern[bytes]``; ``Match`` can be specialised as ``Match[str]`` or
``Match[bytes]... | Deprecated aliases corresponding to the return types from :func:`re.compile` and :func:`re.search`.
These types (and the corresponding functions) are generic over
:data:`AnyStr`. ``Pattern`` can be specialised as ``Pattern[str]`` or
``Pattern[bytes]``; ``Match`` can be specialised as ``Match[str]`` or
``Match[bytes]... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f635522b-2a8e-4ec3-a65e-69265795fef4 | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 31,070 | supabase-export-v2 | bb16fd53be34f101 | key is associated with a value of a consistent type. This expectation is not checked at runtime but is only enforced by type checkers. Usage::
class Point2D(TypedDict):
x: int
y: int
label: str | trusted_official_docs | CPython Docs | key is associated with a value of a consistent type. This expectation is not checked at runtime but is only enforced by type checkers. Usage::
class Point2D(TypedDict):
x: int
y: int
label: str | key is associated with a value of a consistent type. This expectation is not checked at runtime but is only enforced by type checkers. Usage::
class Point2D(TypedDict):
x: int
y: int
label: str | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f66fb7d1-8947-4ae9-97dd-a5863a5b736e | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 30,691 | supabase-export-v2 | 4ae2a9a40de7f6bc | treat the annotation as ``T``. As such, ``Annotated`` can be useful for code that wants to use annotations for purposes outside Python's static typing system.
Using ``Annotated[T, x]`` as an annotation still allows for static
typechecking of ``T``, as type checkers will simply ignore the metadata ``x``. In this way, `... | trusted_official_docs | CPython Docs | treat the annotation as ``T``. As such, ``Annotated`` can be useful for code that wants to use annotations for purposes outside Python's static typing system.
Using ``Annotated[T, x]`` as an annotation still allows for static
typechecking of ``T``, as type checkers will simply ignore the metadata ``x``. In this way, `... | treat the annotation as ``T``. As such, ``Annotated`` can be useful for code that wants to use annotations for purposes outside Python's static typing system.
Using ``Annotated[T, x]`` as an annotation still allows for static
typechecking of ``T``, as type checkers will simply ignore the metadata ``x``. In this way, `... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f725b86d-c9be-41e7-8b9b-5db3550a472d | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 30,743 | supabase-export-v2 | 267541ed965a2b8b | function. ``TypeIs`` only accepts a single type argument. At runtime, functions marked this way should return a boolean and take at least one positional argument.
``TypeIs`` aims to benefit *type narrowing* -- a technique used by static
type checkers to determine a more precise type of an expression within a
program'... | trusted_official_docs | CPython Docs | function. ``TypeIs`` only accepts a single type argument. At runtime, functions marked this way should return a boolean and take at least one positional argument.
``TypeIs`` aims to benefit *type narrowing* -- a technique used by static
type checkers to determine a more precise type of an expression within a
program'... | function. ``TypeIs`` only accepts a single type argument. At runtime, functions marked this way should return a boolean and take at least one positional argument.
``TypeIs`` aims to benefit *type narrowing* -- a technique used by static
type checkers to determine a more precise type of an expression within a
program'... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f7d6c6cf-e166-4952-a4da-cf4fff3f2652 | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 31,193 | supabase-export-v2 | cfc60b7861ec31f7 | presence of ``@dataclass_transform()`` tells a static type checker that the decorated object performs runtime "magic" that transforms a class in a similar way to :deco:`dataclasses.dataclass`.
Example usage with a decorator function: | trusted_official_docs | CPython Docs | presence of ``@dataclass_transform()`` tells a static type checker that the decorated object performs runtime "magic" that transforms a class in a similar way to :deco:`dataclasses.dataclass`.
Example usage with a decorator function: | presence of ``@dataclass_transform()`` tells a static type checker that the decorated object performs runtime "magic" that transforms a class in a similar way to :deco:`dataclasses.dataclass`.
Example usage with a decorator function: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f7fe984b-01c4-4e94-a506-e8c9a42677c8 | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 30,919 | supabase-export-v2 | d19ce30bd2f38e3e | P = ParamSpec('P')
Parameter specification variables exist primarily for the benefit of static
type checkers. They are used to forward the parameter types of one
callable to another callable -- a pattern commonly found in higher order
functions and decorators. They are only valid when used in ``Concatenate``,
or as... | trusted_official_docs | CPython Docs | P = ParamSpec('P')
Parameter specification variables exist primarily for the benefit of static
type checkers. They are used to forward the parameter types of one
callable to another callable -- a pattern commonly found in higher order
functions and decorators. They are only valid when used in ``Concatenate``,
or as... | P = ParamSpec('P')
Parameter specification variables exist primarily for the benefit of static
type checkers. They are used to forward the parameter types of one
callable to another callable -- a pattern commonly found in higher order
functions and decorators. They are only valid when used in ``Concatenate``,
or as... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f82b1950-c694-474e-99cb-0e4da7f43711 | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 30,719 | supabase-export-v2 | 6cefa952692cce28 | .. doctest::
>>> from typing import Annotated, get_type_hints
>>> 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'>... | trusted_official_docs | CPython Docs | .. doctest::
>>> from typing import Annotated, get_type_hints
>>> 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'>... | .. doctest::
>>> from typing import Annotated, get_type_hints
>>> 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'>... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f9e60b07-dd75-4e6a-9352-ddb65a9254dd | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 31,358 | supabase-export-v2 | 86c82d5a1798fc7f | Note that to annotate arguments, it is preferred to use an abstract collection type such as :class:`~collections.abc.Mapping` rather than to use :class:`dict` or :class:`!typing.Dict`.
.. deprecated:: 3.9
:class:`builtins.dict <dict>` now supports subscripting (``[]``). See :pep:`585` and :ref:`types-genericalias`. | trusted_official_docs | CPython Docs | Note that to annotate arguments, it is preferred to use an abstract collection type such as :class:`~collections.abc.Mapping` rather than to use :class:`dict` or :class:`!typing.Dict`.
.. deprecated:: 3.9
:class:`builtins.dict <dict>` now supports subscripting (``[]``). See :pep:`585` and :ref:`types-genericalias`. | Note that to annotate arguments, it is preferred to use an abstract collection type such as :class:`~collections.abc.Mapping` rather than to use :class:`dict` or :class:`!typing.Dict`.
.. deprecated:: 3.9
:class:`builtins.dict <dict>` now supports subscripting (``[]``). See :pep:`585` and :ref:`types-genericalias`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fa7ce8e5-3fa3-414c-823c-92c1abd1fe1e | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 31,349 | supabase-export-v2 | dc735717d14969e0 | Deprecated aliases ------------------
This module defines several deprecated aliases to pre-existing
standard library classes. These were originally included in the :mod:`!typing`
module in order to support parameterizing these generic classes using ``[]``. However, the aliases became redundant in Python 3.9 when the
c... | trusted_official_docs | CPython Docs | Deprecated aliases ------------------
This module defines several deprecated aliases to pre-existing
standard library classes. These were originally included in the :mod:`!typing`
module in order to support parameterizing these generic classes using ``[]``. However, the aliases became redundant in Python 3.9 when the
c... | Deprecated aliases ------------------
This module defines several deprecated aliases to pre-existing
standard library classes. These were originally included in the :mod:`!typing`
module in order to support parameterizing these generic classes using ``[]``. However, the aliases became redundant in Python 3.9 when the
c... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
faf10fb0-0e5c-4fec-b9d1-f0eab6b34ffe | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 30,923 | supabase-export-v2 | ac36fe911759df6b | T]: '''A type-safe decorator to add logging to a function.''' def inner(*args: P.args, **kwargs: P.kwargs) -> T: logging.info(f'{f.__name__} was called') return f(*args, **kwargs) return inner
@add_logging
def add_two(x: float, y: float) -> float:
'''Add two numbers together.'''
return x + y | trusted_official_docs | CPython Docs | T]: '''A type-safe decorator to add logging to a function.''' def inner(*args: P.args, **kwargs: P.kwargs) -> T: logging.info(f'{f.__name__} was called') return f(*args, **kwargs) return inner
@add_logging
def add_two(x: float, y: float) -> float:
'''Add two numbers together.'''
return x + y | T]: '''A type-safe decorator to add logging to a function.''' def inner(*args: P.args, **kwargs: P.kwargs) -> T: logging.info(f'{f.__name__} was called') return f(*args, **kwargs) return inner
@add_logging
def add_two(x: float, y: float) -> float:
'''Add two numbers together.'''
return x + y | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fb41c132-8cdc-4ad0-990c-4c4b8bee0d73 | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 31,090 | supabase-export-v2 | bdacfd11c1aa68fb | # Alternative syntax Point2D = TypedDict('Point2D', { 'x': Required[int], 'y': Required[int], 'label': str }, total=False)
It is possible for a ``TypedDict`` type to inherit from one or more other ``TypedDict`` types
using the class-based syntax. Usage:: | trusted_official_docs | CPython Docs | # Alternative syntax Point2D = TypedDict('Point2D', { 'x': Required[int], 'y': Required[int], 'label': str }, total=False)
It is possible for a ``TypedDict`` type to inherit from one or more other ``TypedDict`` types
using the class-based syntax. Usage:: | # Alternative syntax Point2D = TypedDict('Point2D', { 'x': Required[int], 'y': Required[int], 'label': str }, total=False)
It is possible for a ``TypedDict`` type to inherit from one or more other ``TypedDict`` types
using the class-based syntax. Usage:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fbb18379-3bc5-406c-816c-8b50237fe3d3 | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 30,541 | supabase-export-v2 | 0ebddec045893019 | in the function signature, # so cannot be "solved" by the type checker def greet_bad(cond: bool) -> AnyStr: return "hi there!" if cond else b"greetings!"
# The better way of annotating this function:
def greet_proper(cond: bool) -> str | bytes:
return "hi there!" if cond else b"greetings!" | trusted_official_docs | CPython Docs | in the function signature, # so cannot be "solved" by the type checker def greet_bad(cond: bool) -> AnyStr: return "hi there!" if cond else b"greetings!"
# The better way of annotating this function:
def greet_proper(cond: bool) -> str | bytes:
return "hi there!" if cond else b"greetings!" | in the function signature, # so cannot be "solved" by the type checker def greet_bad(cond: bool) -> AnyStr: return "hi there!" if cond else b"greetings!"
# The better way of annotating this function:
def greet_proper(cond: bool) -> str | bytes:
return "hi there!" if cond else b"greetings!" | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fc090825-0f3f-427d-ba3e-e6d765e320bd | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 30,574 | supabase-export-v2 | 9802cfe43057fafb | class Foo: def return_self(self: Self) -> Self: ... return self
In general, if something returns ``self``, as in the above examples, you
should use ``Self`` as the return annotation. If ``Foo.return_self`` was
annotated as returning ``"Foo"``, then the type checker would infer the
object returned from ``SubclassOfFo... | trusted_official_docs | CPython Docs | class Foo: def return_self(self: Self) -> Self: ... return self
In general, if something returns ``self``, as in the above examples, you
should use ``Self`` as the return annotation. If ``Foo.return_self`` was
annotated as returning ``"Foo"``, then the type checker would infer the
object returned from ``SubclassOfFo... | class Foo: def return_self(self: Self) -> Self: ... return self
In general, if something returns ``self``, as in the above examples, you
should use ``Self`` as the return annotation. If ``Foo.return_self`` was
annotated as returning ``"Foo"``, then the type checker would infer the
object returned from ``SubclassOfFo... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fcd9f5eb-90d8-415a-b794-3b5646d70eb7 | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 31,183 | supabase-export-v2 | 6f3aa1a2efde62a6 | When a static type checker encounters a call to this function, it emits a diagnostic with the inferred type of the argument. For example::
x: int = 1
reveal_type(x) # Revealed type is "builtins.int" | trusted_official_docs | CPython Docs | When a static type checker encounters a call to this function, it emits a diagnostic with the inferred type of the argument. For example::
x: int = 1
reveal_type(x) # Revealed type is "builtins.int" | When a static type checker encounters a call to this function, it emits a diagnostic with the inferred type of the argument. For example::
x: int = 1
reveal_type(x) # Revealed type is "builtins.int" | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fd2ebdac-6244-4fcc-a0ff-de1baebc5c98 | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 30,765 | supabase-export-v2 | 9954841a06a4d3c2 | def is_str_list(val: list[object]) -> TypeGuard[list[str]]: '''Determines whether all objects in the list are strings''' return all(isinstance(x, str) for x in val)
def func1(val: list[object]):
if is_str_list(val):
# Type of ``val`` is narrowed to ``list[str]``. print(" ".join(val))
else:
# Type of ``val`` remains... | trusted_official_docs | CPython Docs | def is_str_list(val: list[object]) -> TypeGuard[list[str]]: '''Determines whether all objects in the list are strings''' return all(isinstance(x, str) for x in val)
def func1(val: list[object]):
if is_str_list(val):
# Type of ``val`` is narrowed to ``list[str]``. print(" ".join(val))
else:
# Type of ``val`` remains... | def is_str_list(val: list[object]) -> TypeGuard[list[str]]: '''Determines whether all objects in the list are strings''' return all(isinstance(x, str) for x in val)
def func1(val: list[object]):
if is_str_list(val):
# Type of ``val`` is narrowed to ``list[str]``. print(" ".join(val))
else:
# Type of ``val`` remains... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fe22ba2b-e5c6-4e6a-adb4-2fae5f4c5243 | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 30,780 | supabase-export-v2 | 7921b14654c3b485 | # This function expects two keyword arguments - `name` of type `str` # and `year` of type `int`. def foo(**kwargs: Unpack[Movie]): ...
See :pep:`692` for more details on using ``Unpack`` for ``**kwargs`` typing. | trusted_official_docs | CPython Docs | # This function expects two keyword arguments - `name` of type `str` # and `year` of type `int`. def foo(**kwargs: Unpack[Movie]): ...
See :pep:`692` for more details on using ``Unpack`` for ``**kwargs`` typing. | # This function expects two keyword arguments - `name` of type `str` # and `year` of type `int`. def foo(**kwargs: Unpack[Movie]): ...
See :pep:`692` for more details on using ``Unpack`` for ``**kwargs`` typing. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ff007dd1-9190-448e-be85-181f903798be | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 31,423 | supabase-export-v2 | 7a25e8431512c0d7 | the object. Other common buffer types such as :class:`memoryview` were also never understood as subtypes of :class:`!ByteString` (either at runtime or by static type checkers).
See :pep:`PEP 688 <688#current-options>` for more details. | trusted_official_docs | CPython Docs | the object. Other common buffer types such as :class:`memoryview` were also never understood as subtypes of :class:`!ByteString` (either at runtime or by static type checkers).
See :pep:`PEP 688 <688#current-options>` for more details. | the object. Other common buffer types such as :class:`memoryview` were also never understood as subtypes of :class:`!ByteString` (either at runtime or by static type checkers).
See :pep:`PEP 688 <688#current-options>` for more details. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ff583205-a544-4525-bcb0-aff40bd6044f | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 30,811 | supabase-export-v2 | 9dbc9babcaf45d14 | Note that type variables can be *bounded*, *constrained*, or neither, but cannot be both bounded *and* constrained.
The variance of type variables is inferred by type checkers when they are created
through the :ref:`type parameter syntax <type-params>` or when
``infer_variance=True`` is passed. Manually created type ... | trusted_official_docs | CPython Docs | Note that type variables can be *bounded*, *constrained*, or neither, but cannot be both bounded *and* constrained.
The variance of type variables is inferred by type checkers when they are created
through the :ref:`type parameter syntax <type-params>` or when
``infer_variance=True`` is passed. Manually created type ... | Note that type variables can be *bounded*, *constrained*, or neither, but cannot be both bounded *and* constrained.
The variance of type variables is inferred by type checkers when they are created
through the :ref:`type parameter syntax <type-params>` or when
``infer_variance=True`` is passed. Manually created type ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fff12867-71d1-4389-8208-b289ce88e367 | CPython Docs | file://datasets/cpython/Doc/library/typing.rst | unknown | 761dcd07-e75b-4e99-a2c4-881ccac2b544 | 31,298 | supabase-export-v2 | df9284c1ff249cbf | .. testcode::
assert get_origin(str) is None
assert get_origin(Dict[str, int]) is dict
assert get_origin(Union[int, str]) is Union
assert get_origin(Annotated[str, "metadata"]) is Annotated
P = ParamSpec('P')
assert get_origin(P.args) is P
assert get_origin(P.kwargs) is P | trusted_official_docs | CPython Docs | .. testcode::
assert get_origin(str) is None
assert get_origin(Dict[str, int]) is dict
assert get_origin(Union[int, str]) is Union
assert get_origin(Annotated[str, "metadata"]) is Annotated
P = ParamSpec('P')
assert get_origin(P.args) is P
assert get_origin(P.kwargs) is P | .. testcode::
assert get_origin(str) is None
assert get_origin(Dict[str, int]) is dict
assert get_origin(Union[int, str]) is Union
assert get_origin(Annotated[str, "metadata"]) is Annotated
P = ParamSpec('P')
assert get_origin(P.args) is P
assert get_origin(P.kwargs) is P | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
01ea8583-886e-4e4d-bcf1-482e0349abc3 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,838 | supabase-export-v2 | 4c255afe463991f7 | Additional processing classes are defined to find, parse, and run, and check doctest examples:
* :class:`DocTestFinder`: Finds all docstrings in a given module, and uses a
:class:`DocTestParser` to create a :class:`DocTest` from every docstring that
contains interactive examples. | trusted_official_docs | CPython Docs | Additional processing classes are defined to find, parse, and run, and check doctest examples:
* :class:`DocTestFinder`: Finds all docstrings in a given module, and uses a
:class:`DocTestParser` to create a :class:`DocTest` from every docstring that
contains interactive examples. | Additional processing classes are defined to find, parse, and run, and check doctest examples:
* :class:`DocTestFinder`: Finds all docstrings in a given module, and uses a
:class:`DocTestParser` to create a :class:`DocTest` from every docstring that
contains interactive examples. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
01edc856-95ff-47d0-912f-6b8cb8b950c7 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,669 | supabase-export-v2 | e42e93c137a9c95a | detail, they are not checked by doctest. For example, the following test would pass, even though it puts the ``^`` marker in the wrong location::
>>> 1 + None
File "<stdin>", line 1
1 + None
^~~~~~~~
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType' | trusted_official_docs | CPython Docs | detail, they are not checked by doctest. For example, the following test would pass, even though it puts the ``^`` marker in the wrong location::
>>> 1 + None
File "<stdin>", line 1
1 + None
^~~~~~~~
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType' | detail, they are not checked by doctest. For example, the following test would pass, even though it puts the ``^`` marker in the wrong location::
>>> 1 + None
File "<stdin>", line 1
1 + None
^~~~~~~~
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType' | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0304087d-b5db-454c-a2f4-8ab6c3c2933e | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,873 | supabase-export-v2 | fca0e3a9a5a31e89 | .. attribute:: lineno
The line number within the string containing this example where the example
begins. This line number is zero-based with respect to the beginning of the
containing string. | trusted_official_docs | CPython Docs | .. attribute:: lineno
The line number within the string containing this example where the example
begins. This line number is zero-based with respect to the beginning of the
containing string. | .. attribute:: lineno
The line number within the string containing this example where the example
begins. This line number is zero-based with respect to the beginning of the
containing string. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
03340f43-6554-4622-97ec-5ad82df4de0e | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,935 | supabase-export-v2 | 7ac37579c5eb47da | Report that the given example failed. This method is provided to allow subclasses of :class:`DocTestRunner` to customize their output; it should not be called directly.
*example* is the example about to be processed. *got* is the actual output
from the example. *test* is the test containing *example*. *out* is the
ou... | trusted_official_docs | CPython Docs | Report that the given example failed. This method is provided to allow subclasses of :class:`DocTestRunner` to customize their output; it should not be called directly.
*example* is the example about to be processed. *got* is the actual output
from the example. *test* is the test containing *example*. *out* is the
ou... | Report that the given example failed. This method is provided to allow subclasses of :class:`DocTestRunner` to customize their output; it should not be called directly.
*example* is the example about to be processed. *got* is the actual output
from the example. *test* is the test containing *example*. *out* is the
ou... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
04dbfc6c-9f9f-426e-9364-319a61c89873 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,937 | supabase-export-v2 | 53566fbe91f18746 | .. method:: report_unexpected_exception(out, test, example, exc_info)
Report that the given example raised an unexpected exception. This method is
provided to allow subclasses of :class:`DocTestRunner` to customize their
output; it should not be called directly. | trusted_official_docs | CPython Docs | .. method:: report_unexpected_exception(out, test, example, exc_info)
Report that the given example raised an unexpected exception. This method is
provided to allow subclasses of :class:`DocTestRunner` to customize their
output; it should not be called directly. | .. method:: report_unexpected_exception(out, test, example, exc_info)
Report that the given example raised an unexpected exception. This method is
provided to allow subclasses of :class:`DocTestRunner` to customize their
output; it should not be called directly. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
051b71b1-614b-41c6-8ab2-1246a8f49988 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,643 | supabase-export-v2 | 5b4b4ec6d3895895 | What's the Execution Context? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
By default, each time :mod:`!doctest` finds a docstring to test, it uses a
*shallow copy* of :mod:`!M`'s globals, so that running tests doesn't change the
module's real globals, and so that one test in :mod:`!M` can't leave behind
crumbs that accidentally allo... | trusted_official_docs | CPython Docs | What's the Execution Context? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
By default, each time :mod:`!doctest` finds a docstring to test, it uses a
*shallow copy* of :mod:`!M`'s globals, so that running tests doesn't change the
module's real globals, and so that one test in :mod:`!M` can't leave behind
crumbs that accidentally allo... | What's the Execution Context? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
By default, each time :mod:`!doctest` finds a docstring to test, it uses a
*shallow copy* of :mod:`!M`'s globals, so that running tests doesn't change the
module's real globals, and so that one test in :mod:`!M` can't leave behind
crumbs that accidentally allo... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
052fb099-9133-4460-8cb9-403088baf7b0 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,534 | supabase-export-v2 | 87c9e052c9d5190d | like interactive Python sessions, and then executes those sessions to verify that they work exactly as shown. There are several common ways to use doctest:
* To check that a module's docstrings are up-to-date by verifying that all
interactive examples still work as documented. | trusted_official_docs | CPython Docs | like interactive Python sessions, and then executes those sessions to verify that they work exactly as shown. There are several common ways to use doctest:
* To check that a module's docstrings are up-to-date by verifying that all
interactive examples still work as documented. | like interactive Python sessions, and then executes those sessions to verify that they work exactly as shown. There are several common ways to use doctest:
* To check that a module's docstrings are up-to-date by verifying that all
interactive examples still work as documented. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0649be22-014d-4611-ba19-8cad326fd2c0 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,543 | supabase-export-v2 | 90f5ccd90919fd3d | in range(6)] [1, 1, 2, 6, 24, 120] >>> factorial(30) 265252859812191058636308480000000 >>> factorial(-1) Traceback (most recent call last): ... ValueError: n must be >= 0
Factorials of floats are OK, but the float must be an exact integer:
>>> factorial(30.1)
Traceback (most recent call last):
... ValueError: n must... | trusted_official_docs | CPython Docs | in range(6)] [1, 1, 2, 6, 24, 120] >>> factorial(30) 265252859812191058636308480000000 >>> factorial(-1) Traceback (most recent call last): ... ValueError: n must be >= 0
Factorials of floats are OK, but the float must be an exact integer:
>>> factorial(30.1)
Traceback (most recent call last):
... ValueError: n must... | in range(6)] [1, 1, 2, 6, 24, 120] >>> factorial(30) 265252859812191058636308480000000 >>> factorial(-1) Traceback (most recent call last): ... ValueError: n must be >= 0
Factorials of floats are OK, but the float must be an exact integer:
>>> factorial(30.1)
Traceback (most recent call last):
... ValueError: n must... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
07037fbf-f3f1-4a05-8483-3b76974ac7e3 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,625 | supabase-export-v2 | 72ceddc6ffcb5b4a | How are Docstring Examples Recognized? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In most cases a copy-and-paste of an interactive console session works fine,
but doctest isn't trying to do an exact emulation of any specific Python shell. | trusted_official_docs | CPython Docs | How are Docstring Examples Recognized? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In most cases a copy-and-paste of an interactive console session works fine,
but doctest isn't trying to do an exact emulation of any specific Python shell. | How are Docstring Examples Recognized? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In most cases a copy-and-paste of an interactive console session works fine,
but doctest isn't trying to do an exact emulation of any specific Python shell. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
072d8ba8-23a3-4543-9762-13104c69c535 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,865 | supabase-export-v2 | 2628a860793ab107 | single interactive example, consisting of a Python statement and its expected output. The constructor arguments are used to initialize the attributes of the same names.
:class:`Example` defines the following attributes. They are initialized by
the constructor, and should not be modified directly. | trusted_official_docs | CPython Docs | single interactive example, consisting of a Python statement and its expected output. The constructor arguments are used to initialize the attributes of the same names.
:class:`Example` defines the following attributes. They are initialized by
the constructor, and should not be modified directly. | single interactive example, consisting of a Python statement and its expected output. The constructor arguments are used to initialize the attributes of the same names.
:class:`Example` defines the following attributes. They are initialized by
the constructor, and should not be modified directly. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
07c7013f-9570-431b-901c-8591e8082789 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,946 | supabase-export-v2 | 5ea3626702a28eb7 | Print a summary of all the test cases that have been run by this DocTestRunner, and return a :class:`TestResults` instance.
The optional *verbose* argument controls how detailed the summary is. If the
verbosity is not specified, then the :class:`DocTestRunner`'s verbosity is
used. | trusted_official_docs | CPython Docs | Print a summary of all the test cases that have been run by this DocTestRunner, and return a :class:`TestResults` instance.
The optional *verbose* argument controls how detailed the summary is. If the
verbosity is not specified, then the :class:`DocTestRunner`'s verbosity is
used. | Print a summary of all the test cases that have been run by this DocTestRunner, and return a :class:`TestResults` instance.
The optional *verbose* argument controls how detailed the summary is. If the
verbosity is not specified, then the :class:`DocTestRunner`'s verbosity is
used. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0955d1a7-e230-4614-82d3-cb3e44941cdc | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,917 | supabase-export-v2 | 04d3d73ba6dd4c4f | for more information. If the option flags are insufficient, then the comparison may also be customized by passing a subclass of :class:`!OutputChecker` to the constructor.
The test runner's display output can be controlled in two ways. First, an output
function can be passed to :meth:`run`; this function will be calle... | trusted_official_docs | CPython Docs | for more information. If the option flags are insufficient, then the comparison may also be customized by passing a subclass of :class:`!OutputChecker` to the constructor.
The test runner's display output can be controlled in two ways. First, an output
function can be passed to :meth:`run`; this function will be calle... | for more information. If the option flags are insufficient, then the comparison may also be customized by passing a subclass of :class:`!OutputChecker` to the constructor.
The test runner's display output can be controlled in two ways. First, an output
function can be passed to :meth:`run`; this function will be calle... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0acf66f7-2062-45b7-acf2-06b3b1d98f14 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,692 | supabase-export-v2 | e52361b869a7ad05 | .. data:: SKIP
When specified, do not run the example at all. This can be useful in contexts
where doctest examples serve as both documentation and test cases, and an
example should be included for documentation purposes, but should not be
checked. E.g., the example's output might be random; or the example might
de... | trusted_official_docs | CPython Docs | .. data:: SKIP
When specified, do not run the example at all. This can be useful in contexts
where doctest examples serve as both documentation and test cases, and an
example should be included for documentation purposes, but should not be
checked. E.g., the example's output might be random; or the example might
de... | .. data:: SKIP
When specified, do not run the example at all. This can be useful in contexts
where doctest examples serve as both documentation and test cases, and an
example should be included for documentation purposes, but should not be
checked. E.g., the example's output might be random; or the example might
de... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0c72605c-786d-4307-9bc9-636724445346 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,842 | supabase-export-v2 | ca6bec808e744250 | * :class:`OutputChecker`: Compares the actual output from a doctest example with the expected output, and decides whether they match.
The relationships among these processing classes are summarized in the following
diagram:: | trusted_official_docs | CPython Docs | * :class:`OutputChecker`: Compares the actual output from a doctest example with the expected output, and decides whether they match.
The relationships among these processing classes are summarized in the following
diagram:: | * :class:`OutputChecker`: Compares the actual output from a doctest example with the expected output, and decides whether they match.
The relationships among these processing classes are summarized in the following
diagram:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0cccd4b1-aae5-416f-93d1-267bbe163418 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,535 | supabase-export-v2 | aa6b013e793fadc3 | * To check that a module's docstrings are up-to-date by verifying that all interactive examples still work as documented.
* To perform regression testing by verifying that interactive examples from a
test file or a test object work as expected. | trusted_official_docs | CPython Docs | * To check that a module's docstrings are up-to-date by verifying that all interactive examples still work as documented.
* To perform regression testing by verifying that interactive examples from a
test file or a test object work as expected. | * To check that a module's docstrings are up-to-date by verifying that all interactive examples still work as documented.
* To perform regression testing by verifying that interactive examples from a
test file or a test object work as expected. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0fcc6da5-8dbc-4721-8f60-ed41ecb3a6f2 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,702 | supabase-export-v2 | 1c9de7b979998c98 | .. data:: REPORT_NDIFF
When specified, differences are computed by ``difflib.Differ``, using the same
algorithm as the popular :file:`ndiff.py` utility. This is the only method that
marks differences within lines as well as across lines. For example, if a line
of expected output contains digit ``1`` where actual out... | trusted_official_docs | CPython Docs | .. data:: REPORT_NDIFF
When specified, differences are computed by ``difflib.Differ``, using the same
algorithm as the popular :file:`ndiff.py` utility. This is the only method that
marks differences within lines as well as across lines. For example, if a line
of expected output contains digit ``1`` where actual out... | .. data:: REPORT_NDIFF
When specified, differences are computed by ``difflib.Differ``, using the same
algorithm as the popular :file:`ndiff.py` utility. This is the only method that
marks differences within lines as well as across lines. For example, if a line
of expected output contains digit ``1`` where actual out... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1004b77e-2e9c-4f6c-946e-e7d06f10379b | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,683 | supabase-export-v2 | e93336ce8d69006d | .. data:: IGNORE_EXCEPTION_DETAIL
When specified, doctests expecting exceptions pass so long as an exception
of the expected type is raised, even if the details
(message and fully qualified exception name) don't match. | trusted_official_docs | CPython Docs | .. data:: IGNORE_EXCEPTION_DETAIL
When specified, doctests expecting exceptions pass so long as an exception
of the expected type is raised, even if the details
(message and fully qualified exception name) don't match. | .. data:: IGNORE_EXCEPTION_DETAIL
When specified, doctests expecting exceptions pass so long as an exception
of the expected type is raised, even if the details
(message and fully qualified exception name) don't match. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
10dc6dc9-4818-4dba-9c7e-249dbb660a47 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,745 | supabase-export-v2 | 965646e10421ff84 | .. doctest::
>>> id(1.0) # certain to fail some of the time # doctest: +SKIP
7948648
>>> class C: pass
>>> C() # the default repr() for instances embeds an address # doctest: +SKIP
<C object at 0x00AC18F0> | trusted_official_docs | CPython Docs | .. doctest::
>>> id(1.0) # certain to fail some of the time # doctest: +SKIP
7948648
>>> class C: pass
>>> C() # the default repr() for instances embeds an address # doctest: +SKIP
<C object at 0x00AC18F0> | .. doctest::
>>> id(1.0) # certain to fail some of the time # doctest: +SKIP
7948648
>>> class C: pass
>>> C() # the default repr() for instances embeds an address # doctest: +SKIP
<C object at 0x00AC18F0> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
10f1d01e-f854-471b-8d77-d317b4a67f73 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,918 | supabase-export-v2 | 785b3ed4f011ef81 | output is not sufficient, then the display output can be also customized by subclassing DocTestRunner, and overriding the methods :meth:`report_skip`, :meth:`report_start`, :meth:`report_success`, :meth:`report_unexpected_exception`, and :meth:`report_failure`.
The optional keyword argument *checker* specifies the :cla... | trusted_official_docs | CPython Docs | output is not sufficient, then the display output can be also customized by subclassing DocTestRunner, and overriding the methods :meth:`report_skip`, :meth:`report_start`, :meth:`report_success`, :meth:`report_unexpected_exception`, and :meth:`report_failure`.
The optional keyword argument *checker* specifies the :cla... | output is not sufficient, then the display output can be also customized by subclassing DocTestRunner, and overriding the methods :meth:`report_skip`, :meth:`report_start`, :meth:`report_success`, :meth:`report_unexpected_exception`, and :meth:`report_failure`.
The optional keyword argument *checker* specifies the :cla... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
131d8677-2080-44cc-bb4d-28e377a2b8c5 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,797 | supabase-export-v2 | 4a463b4c4086dfea | and a (sometimes approximate) line number. If all the examples in a file are skipped, then the synthesized unit test is also marked as skipped.
Pass one or more paths (as strings) to text files to be examined. | trusted_official_docs | CPython Docs | and a (sometimes approximate) line number. If all the examples in a file are skipped, then the synthesized unit test is also marked as skipped.
Pass one or more paths (as strings) to text files to be examined. | and a (sometimes approximate) line number. If all the examples in a file are skipped, then the synthesized unit test is also marked as skipped.
Pass one or more paths (as strings) to text files to be examined. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
13b61813-5925-4906-a98b-4732dcf3c09e | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,787 | supabase-export-v2 | fa7ca9e3e1eed285 | the Python compiler when running the examples. By default, or if ``None``, flags are deduced corresponding to the set of future features found in *globs*.
Optional argument *optionflags* works as for function :func:`testfile` above. | trusted_official_docs | CPython Docs | the Python compiler when running the examples. By default, or if ``None``, flags are deduced corresponding to the set of future features found in *globs*.
Optional argument *optionflags* works as for function :func:`testfile` above. | the Python compiler when running the examples. By default, or if ``None``, flags are deduced corresponding to the set of future features found in *globs*.
Optional argument *optionflags* works as for function :func:`testfile` above. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1411364c-7db8-44c5-95d5-95abeb5ec038 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,942 | supabase-export-v2 | 7440077d49a3d395 | cleared after the test runs, to help with garbage collection. If you would like to examine the namespace after the test completes, then use *clear_globs=False*.
*compileflags* gives the set of flags that should be used by the Python
compiler when running the examples. If not specified, then it will default to
the set... | trusted_official_docs | CPython Docs | cleared after the test runs, to help with garbage collection. If you would like to examine the namespace after the test completes, then use *clear_globs=False*.
*compileflags* gives the set of flags that should be used by the Python
compiler when running the examples. If not specified, then it will default to
the set... | cleared after the test runs, to help with garbage collection. If you would like to examine the namespace after the test completes, then use *clear_globs=False*.
*compileflags* gives the set of flags that should be used by the Python
compiler when running the examples. If not specified, then it will default to
the set... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1474a2d6-0770-4d2b-873a-8549517f6083 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,566 | supabase-export-v2 | 045ed9ff1ccb15c2 | failure(s) are printed to stdout, and the final line of output is ``***Test Failed*** N failures.``, where *N* is the number of examples that failed.
Run it with the ``-v`` switch instead:: | trusted_official_docs | CPython Docs | failure(s) are printed to stdout, and the final line of output is ``***Test Failed*** N failures.``, where *N* is the number of examples that failed.
Run it with the ``-v`` switch instead:: | failure(s) are printed to stdout, and the final line of output is ``***Test Failed*** N failures.``, where *N* is the number of examples that failed.
Run it with the ``-v`` switch instead:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
156c1f16-5e43-4ff2-a34a-cd7bb815eab6 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,885 | supabase-export-v2 | 9b5206857f65a850 | If the optional argument *recurse* is false, then :meth:`DocTestFinder.find` will only examine the given object, and not any contained objects.
If the optional argument *exclude_empty* is false, then
:meth:`DocTestFinder.find` will include tests for objects with empty docstrings. | trusted_official_docs | CPython Docs | If the optional argument *recurse* is false, then :meth:`DocTestFinder.find` will only examine the given object, and not any contained objects.
If the optional argument *exclude_empty* is false, then
:meth:`DocTestFinder.find` will include tests for objects with empty docstrings. | If the optional argument *recurse* is false, then :meth:`DocTestFinder.find` will only examine the given object, and not any contained objects.
If the optional argument *exclude_empty* is false, then
:meth:`DocTestFinder.find` will include tests for objects with empty docstrings. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1592cc67-5fe0-4e0d-ae8b-4c614400d6c8 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,996 | supabase-export-v2 | e009f764e7d9b1e2 | .. class:: DebugRunner(checker=None, verbose=None, optionflags=0)
A subclass of :class:`DocTestRunner` that raises an exception as soon as a
failure is encountered. If an unexpected exception occurs, an
:exc:`UnexpectedException` exception is raised, containing the test, the
example, and the original exception. If t... | trusted_official_docs | CPython Docs | .. class:: DebugRunner(checker=None, verbose=None, optionflags=0)
A subclass of :class:`DocTestRunner` that raises an exception as soon as a
failure is encountered. If an unexpected exception occurs, an
:exc:`UnexpectedException` exception is raised, containing the test, the
example, and the original exception. If t... | .. class:: DebugRunner(checker=None, verbose=None, optionflags=0)
A subclass of :class:`DocTestRunner` that raises an exception as soon as a
failure is encountered. If an unexpected exception occurs, an
:exc:`UnexpectedException` exception is raised, containing the test, the
example, and the original exception. If t... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
16042fe9-0288-48c0-ac6a-ed593919c764 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,867 | supabase-export-v2 | 4b4b78142294a797 | .. attribute:: source
A string containing the example's source code. This source code consists of a
single Python statement, and always ends with a newline; the constructor adds
a newline when necessary. | trusted_official_docs | CPython Docs | .. attribute:: source
A string containing the example's source code. This source code consists of a
single Python statement, and always ends with a newline; the constructor adds
a newline when necessary. | .. attribute:: source
A string containing the example's source code. This source code consists of a
single Python statement, and always ends with a newline; the constructor adds
a newline when necessary. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
16374e52-1687-4e9d-93d5-a0d503c291d1 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,960 | supabase-export-v2 | fc80644c8e42c9eb | .. method:: output_difference(example, got, optionflags)
Return a string describing the differences between the expected output for a
given example (*example*) and the actual output (*got*). *optionflags* is the
set of option flags used to compare *want* and *got*. | trusted_official_docs | CPython Docs | .. method:: output_difference(example, got, optionflags)
Return a string describing the differences between the expected output for a
given example (*example*) and the actual output (*got*). *optionflags* is the
set of option flags used to compare *want* and *got*. | .. method:: output_difference(example, got, optionflags)
Return a string describing the differences between the expected output for a
given example (*example*) and the actual output (*got*). *optionflags* is the
set of option flags used to compare *want* and *got*. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
18873a3f-2d20-46ef-8358-715aebc178e2 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 32,031 | supabase-export-v2 | d7972bd4c496a187 | for your test runner to re-run only the failing doctest while you debug the problem. Here is a minimal example of such a test runner::
if __name__ == '__main__':
import doctest
flags = doctest.REPORT_NDIFF|doctest.FAIL_FAST
if len(sys.argv) > 1:
name = sys.argv[1]
if name in globals():
obj = globals()[name]
else... | trusted_official_docs | CPython Docs | for your test runner to re-run only the failing doctest while you debug the problem. Here is a minimal example of such a test runner::
if __name__ == '__main__':
import doctest
flags = doctest.REPORT_NDIFF|doctest.FAIL_FAST
if len(sys.argv) > 1:
name = sys.argv[1]
if name in globals():
obj = globals()[name]
else... | for your test runner to re-run only the failing doctest while you debug the problem. Here is a minimal example of such a test runner::
if __name__ == '__main__':
import doctest
flags = doctest.REPORT_NDIFF|doctest.FAIL_FAST
if len(sys.argv) > 1:
name = sys.argv[1]
if name in globals():
obj = globals()[name]
else... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1a122f56-5803-4aea-a18f-f706237943b1 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,802 | supabase-export-v2 | 128e4514dd2184d1 | filename in *paths* specifies an OS-specific path. The path may be absolute or relative; relative paths are resolved with respect to the current working directory.
Optional argument *package* is a Python package or the name of a Python
package whose directory should be used as the base directory for
module-relative f... | trusted_official_docs | CPython Docs | filename in *paths* specifies an OS-specific path. The path may be absolute or relative; relative paths are resolved with respect to the current working directory.
Optional argument *package* is a Python package or the name of a Python
package whose directory should be used as the base directory for
module-relative f... | filename in *paths* specifies an OS-specific path. The path may be absolute or relative; relative paths are resolved with respect to the current working directory.
Optional argument *package* is a Python package or the name of a Python
package whose directory should be used as the base directory for
module-relative f... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1ac8c812-3ca0-43be-8a89-b41a914aa3b2 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,544 | supabase-export-v2 | c7830419fa3db530 | but the float must be an exact integer: >>> factorial(30.1) Traceback (most recent call last): ... ValueError: n must be exact integer >>> factorial(30.0) 265252859812191058636308480000000
It must also not be ridiculously large:
>>> factorial(1e100)
Traceback (most recent call last):
... OverflowError: n too large
... | trusted_official_docs | CPython Docs | but the float must be an exact integer: >>> factorial(30.1) Traceback (most recent call last): ... ValueError: n must be exact integer >>> factorial(30.0) 265252859812191058636308480000000
It must also not be ridiculously large:
>>> factorial(1e100)
Traceback (most recent call last):
... OverflowError: n too large
... | but the float must be an exact integer: >>> factorial(30.1) Traceback (most recent call last): ... ValueError: n must be exact integer >>> factorial(30.0) 265252859812191058636308480000000
It must also not be ridiculously large:
>>> factorial(1e100)
Traceback (most recent call last):
... OverflowError: n too large
... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1b1c2c5d-533a-4207-b228-4ac337b15d82 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,634 | supabase-export-v2 | 8385934f45c78fc5 | * Output to stdout is captured, but not output to stderr (exception tracebacks are captured via a different means).
* If you continue a line via backslashing in an interactive session, or for any
other reason use a backslash, you should use a raw docstring, which will
preserve your backslashes exactly as you type the... | trusted_official_docs | CPython Docs | * Output to stdout is captured, but not output to stderr (exception tracebacks are captured via a different means).
* If you continue a line via backslashing in an interactive session, or for any
other reason use a backslash, you should use a raw docstring, which will
preserve your backslashes exactly as you type the... | * Output to stdout is captured, but not output to stderr (exception tracebacks are captured via a different means).
* If you continue a line via backslashing in an interactive session, or for any
other reason use a backslash, you should use a raw docstring, which will
preserve your backslashes exactly as you type the... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1c301ec3-e9e8-44e8-b05b-579bf6b6ae32 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,955 | supabase-export-v2 | 56e897e11ac6ecd4 | .. class:: OutputChecker()
A class used to check the whether the actual output from a doctest example
matches the expected output. :class:`OutputChecker` defines two methods:
:meth:`check_output`, which compares a given pair of outputs, and returns ``True``
if they match; and :meth:`output_difference`, which returns... | trusted_official_docs | CPython Docs | .. class:: OutputChecker()
A class used to check the whether the actual output from a doctest example
matches the expected output. :class:`OutputChecker` defines two methods:
:meth:`check_output`, which compares a given pair of outputs, and returns ``True``
if they match; and :meth:`output_difference`, which returns... | .. class:: OutputChecker()
A class used to check the whether the actual output from a doctest example
matches the expected output. :class:`OutputChecker` defines two methods:
:meth:`check_output`, which compares a given pair of outputs, and returns ``True``
if they match; and :meth:`output_difference`, which returns... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1ce92074-3133-40d9-9f5a-c40d1b96fca3 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,809 | supabase-export-v2 | 1713625a49ac9dc7 | Optional argument *encoding* specifies an encoding that should be used to convert the file to unicode.
The global ``__file__`` is added to the globals provided to doctests loaded
from a text file using :func:`DocFileSuite`. | trusted_official_docs | CPython Docs | Optional argument *encoding* specifies an encoding that should be used to convert the file to unicode.
The global ``__file__`` is added to the globals provided to doctests loaded
from a text file using :func:`DocFileSuite`. | Optional argument *encoding* specifies an encoding that should be used to convert the file to unicode.
The global ``__file__`` is added to the globals provided to doctests loaded
from a text file using :func:`DocFileSuite`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1e1b11c9-f40c-418d-b7b2-4dd2887ca68f | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,825 | supabase-export-v2 | 40f8677090a2a8ce | to control :mod:`!doctest` reporting options (perhaps, e.g., specified by command line options), but there's no way to pass options through :mod:`!unittest` to :mod:`!doctest` test runners.
For this reason, :mod:`!doctest` also supports a notion of :mod:`!doctest`
reporting flags specific to :mod:`unittest` support, vi... | trusted_official_docs | CPython Docs | to control :mod:`!doctest` reporting options (perhaps, e.g., specified by command line options), but there's no way to pass options through :mod:`!unittest` to :mod:`!doctest` test runners.
For this reason, :mod:`!doctest` also supports a notion of :mod:`!doctest`
reporting flags specific to :mod:`unittest` support, vi... | to control :mod:`!doctest` reporting options (perhaps, e.g., specified by command line options), but there's no way to pass options through :mod:`!unittest` to :mod:`!doctest` test runners.
For this reason, :mod:`!doctest` also supports a notion of :mod:`!doctest`
reporting flags specific to :mod:`unittest` support, vi... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
20f0a045-f94b-4ea7-a368-615b1921f589 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,749 | supabase-export-v2 | 38e9f7f0bb3c547c | >>> C() # doctest: +ELLIPSIS <C object at 0x...>
Floating-point numbers are also subject to small output variations across
platforms, because Python defers to the platform C library for some
floating-point calculations, and C libraries vary widely in quality here. :: | trusted_official_docs | CPython Docs | >>> C() # doctest: +ELLIPSIS <C object at 0x...>
Floating-point numbers are also subject to small output variations across
platforms, because Python defers to the platform C library for some
floating-point calculations, and C libraries vary widely in quality here. :: | >>> C() # doctest: +ELLIPSIS <C object at 0x...>
Floating-point numbers are also subject to small output variations across
platforms, because Python defers to the platform C library for some
floating-point calculations, and C libraries vary widely in quality here. :: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
219add9e-9215-4186-b5d2-075a267beede | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,958 | supabase-export-v2 | 3a181d03214cd861 | .. method:: check_output(want, got, optionflags)
Return ``True`` iff the actual output from an example (*got*) matches the
expected output (*want*). These strings are always considered to match if
they are identical; but depending on what option flags the test runner is
using, several non-exact match types are also ... | trusted_official_docs | CPython Docs | .. method:: check_output(want, got, optionflags)
Return ``True`` iff the actual output from an example (*got*) matches the
expected output (*want*). These strings are always considered to match if
they are identical; but depending on what option flags the test runner is
using, several non-exact match types are also ... | .. method:: check_output(want, got, optionflags)
Return ``True`` iff the actual output from an example (*got*) matches the
expected output (*want*). These strings are always considered to match if
they are identical; but depending on what option flags the test runner is
using, several non-exact match types are also ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
226308ef-39e5-45ce-a086-58aa7e1b5d4a | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,881 | supabase-export-v2 | e74609840c2326aa | .. class:: DocTestFinder(verbose=False, parser=DocTestParser(), recurse=True, exclude_empty=True)
A processing class used to extract the :class:`DocTest`\ s that are relevant to
a given object, from its docstring and the docstrings of its contained objects. :class:`DocTest`\ s can be extracted from modules, classes, f... | trusted_official_docs | CPython Docs | .. class:: DocTestFinder(verbose=False, parser=DocTestParser(), recurse=True, exclude_empty=True)
A processing class used to extract the :class:`DocTest`\ s that are relevant to
a given object, from its docstring and the docstrings of its contained objects. :class:`DocTest`\ s can be extracted from modules, classes, f... | .. class:: DocTestFinder(verbose=False, parser=DocTestParser(), recurse=True, exclude_empty=True)
A processing class used to extract the :class:`DocTest`\ s that are relevant to
a given object, from its docstring and the docstrings of its contained objects. :class:`DocTest`\ s can be extracted from modules, classes, f... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
2346e27d-ecf9-4b8f-8373-0bf41722fdf0 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,765 | supabase-export-v2 | 493eaca8aa21ef70 | dict is created for the doctest, so its examples start with a clean slate. By default, or if ``None``, a new empty dict is used.
Optional argument *extraglobs* gives a dict merged into the globals used to
execute examples. This works like :meth:`dict.update`: if *globs* and
*extraglobs* have a common key, the associa... | trusted_official_docs | CPython Docs | dict is created for the doctest, so its examples start with a clean slate. By default, or if ``None``, a new empty dict is used.
Optional argument *extraglobs* gives a dict merged into the globals used to
execute examples. This works like :meth:`dict.update`: if *globs* and
*extraglobs* have a common key, the associa... | dict is created for the doctest, so its examples start with a clean slate. By default, or if ``None``, a new empty dict is used.
Optional argument *extraglobs* gives a dict merged into the globals used to
execute examples. This works like :meth:`dict.update`: if *globs* and
*extraglobs* have a common key, the associa... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
237d89c3-3dd1-4d17-8be5-7e06f83acefe | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,640 | supabase-export-v2 | 276be19b2280171d | >>> assert "Easy!" >>> import math >>> math.floor(1.9) 1
and as many leading whitespace characters are stripped from the expected output
as appeared in the initial ``'>>> '`` line that started the example. | trusted_official_docs | CPython Docs | >>> assert "Easy!" >>> import math >>> math.floor(1.9) 1
and as many leading whitespace characters are stripped from the expected output
as appeared in the initial ``'>>> '`` line that started the example. | >>> assert "Easy!" >>> import math >>> math.floor(1.9) 1
and as many leading whitespace characters are stripped from the expected output
as appeared in the initial ``'>>> '`` line that started the example. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
252d3688-920d-4057-8a46-55f3d71a83eb | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 32,023 | supabase-export-v2 | 60c9d36bb6e2b02d | These uses have different requirements, and it is important to distinguish them. In particular, filling your docstrings with obscure test cases makes for bad documentation.
When writing a docstring, choose docstring examples with care. There's an art to
this that needs to be learned---it may not be natural at first. Ex... | trusted_official_docs | CPython Docs | These uses have different requirements, and it is important to distinguish them. In particular, filling your docstrings with obscure test cases makes for bad documentation.
When writing a docstring, choose docstring examples with care. There's an art to
this that needs to be learned---it may not be natural at first. Ex... | These uses have different requirements, and it is important to distinguish them. In particular, filling your docstrings with obscure test cases makes for bad documentation.
When writing a docstring, choose docstring examples with care. There's an art to
this that needs to be learned---it may not be natural at first. Ex... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
26034514-2641-444c-8a96-6d3f59738034 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,936 | supabase-export-v2 | 1c84d9c74966eefb | processed. *got* is the actual output from the example. *test* is the test containing *example*. *out* is the output function that was passed to :meth:`DocTestRunner.run`.
.. method:: report_unexpected_exception(out, test, example, exc_info) | trusted_official_docs | CPython Docs | processed. *got* is the actual output from the example. *test* is the test containing *example*. *out* is the output function that was passed to :meth:`DocTestRunner.run`.
.. method:: report_unexpected_exception(out, test, example, exc_info) | processed. *got* is the actual output from the example. *test* is the test containing *example*. *out* is the output function that was passed to :meth:`DocTestRunner.run`.
.. method:: report_unexpected_exception(out, test, example, exc_info) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
266fbecd-283a-4a64-b7cb-eff713adf214 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,667 | supabase-export-v2 | 4137f10434922f0f | * For some exceptions, Python displays the position of the error using ``^`` markers and tildes::
>>> 1 + None
File "<stdin>", line 1
1 + None
~~^~~~~~
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType' | trusted_official_docs | CPython Docs | * For some exceptions, Python displays the position of the error using ``^`` markers and tildes::
>>> 1 + None
File "<stdin>", line 1
1 + None
~~^~~~~~
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType' | * For some exceptions, Python displays the position of the error using ``^`` markers and tildes::
>>> 1 + None
File "<stdin>", line 1
1 + None
~~^~~~~~
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType' | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
26f39b86-10bf-49f3-9d5d-366c51cd9d0e | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,766 | supabase-export-v2 | d8148f6a3aaf8234 | the class, then reused to test any number of subclasses by passing an *extraglobs* dict mapping the generic name to the subclass to be tested.
Optional argument *verbose* prints lots of stuff if true, and prints only
failures if false; by default, or if ``None``, it's true if and only if ``'-v'``
is in :data:`sys.arg... | trusted_official_docs | CPython Docs | the class, then reused to test any number of subclasses by passing an *extraglobs* dict mapping the generic name to the subclass to be tested.
Optional argument *verbose* prints lots of stuff if true, and prints only
failures if false; by default, or if ``None``, it's true if and only if ``'-v'``
is in :data:`sys.arg... | the class, then reused to test any number of subclasses by passing an *extraglobs* dict mapping the generic name to the subclass to be tested.
Optional argument *verbose* prints lots of stuff if true, and prints only
failures if false; by default, or if ``None``, it's true if and only if ``'-v'``
is in :data:`sys.arg... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
26f68057-7332-48a9-b33a-72cd6d82433d | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,774 | supabase-export-v2 | b8b6a35e79eecd5a | All arguments are optional, and all except for *m* should be specified in keyword form.
Test examples in docstrings in functions and classes reachable from module *m*
(or module :mod:`__main__` if *m* is not supplied or is ``None``), starting with
``m.__doc__``. | trusted_official_docs | CPython Docs | All arguments are optional, and all except for *m* should be specified in keyword form.
Test examples in docstrings in functions and classes reachable from module *m*
(or module :mod:`__main__` if *m* is not supplied or is ``None``), starting with
``m.__doc__``. | All arguments are optional, and all except for *m* should be specified in keyword form.
Test examples in docstrings in functions and classes reachable from module *m*
(or module :mod:`__main__` if *m* is not supplied or is ``None``), starting with
``m.__doc__``. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
289828a7-bf5a-4586-8385-4e980cc19464 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,665 | supabase-export-v2 | 4636c710207161c4 | you need to test a :exc:`!SyntaxError` that omits the traceback header, you will need to manually add the traceback header line to your test example.
.. index:: single: ^ (caret); marker | trusted_official_docs | CPython Docs | you need to test a :exc:`!SyntaxError` that omits the traceback header, you will need to manually add the traceback header line to your test example.
.. index:: single: ^ (caret); marker | you need to test a :exc:`!SyntaxError` that omits the traceback header, you will need to manually add the traceback header line to your test example.
.. index:: single: ^ (caret); marker | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
28c08f13-46b5-443e-8f09-08263e270788 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,890 | supabase-export-v2 | 8e0ee5ee68afaa4e | the object's name; this name will be used to construct names for the returned :class:`DocTest`\ s. If *name* is not specified, then ``obj.__name__`` is used.
The optional parameter *module* is the module that contains the given object. If the module is not specified or is ``None``, then the test finder will attempt
to... | trusted_official_docs | CPython Docs | the object's name; this name will be used to construct names for the returned :class:`DocTest`\ s. If *name* is not specified, then ``obj.__name__`` is used.
The optional parameter *module* is the module that contains the given object. If the module is not specified or is ``None``, then the test finder will attempt
to... | the object's name; this name will be used to construct names for the returned :class:`DocTest`\ s. If *name* is not specified, then ``obj.__name__`` is used.
The optional parameter *module* is the module that contains the given object. If the module is not specified or is ``None``, then the test finder will attempt
to... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
2940b611-6d22-40fa-b3b9-c20aecffe76e | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,882 | supabase-export-v2 | 2b159f0deba72bd1 | object, from its docstring and the docstrings of its contained objects. :class:`DocTest`\ s can be extracted from modules, classes, functions, methods, staticmethods, classmethods, and properties.
The optional argument *verbose* can be used to display the objects searched by
the finder. It defaults to ``False`` (no ou... | trusted_official_docs | CPython Docs | object, from its docstring and the docstrings of its contained objects. :class:`DocTest`\ s can be extracted from modules, classes, functions, methods, staticmethods, classmethods, and properties.
The optional argument *verbose* can be used to display the objects searched by
the finder. It defaults to ``False`` (no ou... | object, from its docstring and the docstrings of its contained objects. :class:`DocTest`\ s can be extracted from modules, classes, functions, methods, staticmethods, classmethods, and properties.
The optional argument *verbose* can be used to display the objects searched by
the finder. It defaults to ``False`` (no ou... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
2bce66f7-0a46-46c6-9e17-ab6d29bc0a01 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,565 | supabase-export-v2 | b95a28f14a10c558 | python M.py
This won't display anything unless an example fails, in which case the failing
example(s) and the cause(s) of the failure(s) are printed to stdout, and the
final line of output is ``***Test Failed*** N failures.``, where *N* is the
number of examples that failed. | trusted_official_docs | CPython Docs | python M.py
This won't display anything unless an example fails, in which case the failing
example(s) and the cause(s) of the failure(s) are printed to stdout, and the
final line of output is ``***Test Failed*** N failures.``, where *N* is the
number of examples that failed. | python M.py
This won't display anything unless an example fails, in which case the failing
example(s) and the cause(s) of the failure(s) are printed to stdout, and the
final line of output is ``***Test Failed*** N failures.``, where *N* is the
number of examples that failed. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
2f1b6b18-a800-49f4-91c2-7d90ec64b57e | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,858 | supabase-export-v2 | ae3e478fcd7de79d | .. attribute:: lineno
The line number within :attr:`filename` where this :class:`DocTest` begins, or
``None`` if the line number is unavailable. This line number is zero-based
with respect to the beginning of the file. | trusted_official_docs | CPython Docs | .. attribute:: lineno
The line number within :attr:`filename` where this :class:`DocTest` begins, or
``None`` if the line number is unavailable. This line number is zero-based
with respect to the beginning of the file. | .. attribute:: lineno
The line number within :attr:`filename` where this :class:`DocTest` begins, or
``None`` if the line number is unavailable. This line number is zero-based
with respect to the beginning of the file. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
2ff5f492-ff18-411c-b790-509256af37f5 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,892 | supabase-export-v2 | cadae7980148b9e2 | * As a default namespace, if *globs* is not specified.
* To prevent the DocTestFinder from extracting DocTests from objects that are
imported from other modules. (Contained objects with modules other than
*module* are ignored.) | trusted_official_docs | CPython Docs | * As a default namespace, if *globs* is not specified.
* To prevent the DocTestFinder from extracting DocTests from objects that are
imported from other modules. (Contained objects with modules other than
*module* are ignored.) | * As a default namespace, if *globs* is not specified.
* To prevent the DocTestFinder from extracting DocTests from objects that are
imported from other modules. (Contained objects with modules other than
*module* are ignored.) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3190a47b-1c0b-405d-ae10-d5a14f28b774 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,893 | supabase-export-v2 | 20a3bb23dba89299 | * To prevent the DocTestFinder from extracting DocTests from objects that are imported from other modules. (Contained objects with modules other than *module* are ignored.)
* To find the name of the file containing the object. | trusted_official_docs | CPython Docs | * To prevent the DocTestFinder from extracting DocTests from objects that are imported from other modules. (Contained objects with modules other than *module* are ignored.)
* To find the name of the file containing the object. | * To prevent the DocTestFinder from extracting DocTests from objects that are imported from other modules. (Contained objects with modules other than *module* are ignored.)
* To find the name of the file containing the object. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3192b1b2-91ef-412a-9c6c-7c85fd857dd7 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,637 | supabase-export-v2 | 055d27b6580192b0 | ``\n`` above would be interpreted as a newline character. Alternatively, you can double each backslash in the doctest version (and not use a raw string)::
>>> def f(x):
... '''Backslashes in a raw docstring: m\\n'''
... >>> print(f.__doc__)
Backslashes in a raw docstring: m\n | trusted_official_docs | CPython Docs | ``\n`` above would be interpreted as a newline character. Alternatively, you can double each backslash in the doctest version (and not use a raw string)::
>>> def f(x):
... '''Backslashes in a raw docstring: m\\n'''
... >>> print(f.__doc__)
Backslashes in a raw docstring: m\n | ``\n`` above would be interpreted as a newline character. Alternatively, you can double each backslash in the doctest version (and not use a raw string)::
>>> def f(x):
... '''Backslashes in a raw docstring: m\\n'''
... >>> print(f.__doc__)
Backslashes in a raw docstring: m\n | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
31f93495-5a68-4f21-914b-571a39466078 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,833 | supabase-export-v2 | ddbeb2dab8cf8142 | Advanced API ------------
The basic API is a simple wrapper that's intended to make doctest easy to use. It is fairly flexible, and should meet most users' needs; however, if you
require more fine-grained control over testing, or wish to extend doctest's
capabilities, then you should use the advanced API. | trusted_official_docs | CPython Docs | Advanced API ------------
The basic API is a simple wrapper that's intended to make doctest easy to use. It is fairly flexible, and should meet most users' needs; however, if you
require more fine-grained control over testing, or wish to extend doctest's
capabilities, then you should use the advanced API. | Advanced API ------------
The basic API is a simple wrapper that's intended to make doctest easy to use. It is fairly flexible, and should meet most users' needs; however, if you
require more fine-grained control over testing, or wish to extend doctest's
capabilities, then you should use the advanced API. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3237d237-ed59-4673-a293-fb7e6e1d04be | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,763 | supabase-export-v2 | 0a754f87f0002828 | Optional argument *name* gives the name of the test; by default, or if ``None``, ``os.path.basename(filename)`` is used.
Optional argument *package* is a Python package or the name of a Python package
whose directory should be used as the base directory for a module-relative
filename. If no package is specified, then... | trusted_official_docs | CPython Docs | Optional argument *name* gives the name of the test; by default, or if ``None``, ``os.path.basename(filename)`` is used.
Optional argument *package* is a Python package or the name of a Python package
whose directory should be used as the base directory for a module-relative
filename. If no package is specified, then... | Optional argument *name* gives the name of the test; by default, or if ``None``, ``os.path.basename(filename)`` is used.
Optional argument *package* is a Python package or the name of a Python package
whose directory should be used as the base directory for a module-relative
filename. If no package is specified, then... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3294f34b-e162-4188-9ba0-8bf64108577f | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,993 | supabase-export-v2 | f7cb2be8191db90f | Optional argument *pm* has the same meaning as in function :func:`debug` above.
Optional argument *globs* gives a dictionary to use as both local and global
execution context. If not specified, or ``None``, an empty dictionary is used. If specified, a shallow copy of the dictionary is used. | trusted_official_docs | CPython Docs | Optional argument *pm* has the same meaning as in function :func:`debug` above.
Optional argument *globs* gives a dictionary to use as both local and global
execution context. If not specified, or ``None``, an empty dictionary is used. If specified, a shallow copy of the dictionary is used. | Optional argument *pm* has the same meaning as in function :func:`debug` above.
Optional argument *globs* gives a dictionary to use as both local and global
execution context. If not specified, or ``None``, an empty dictionary is used. If specified, a shallow copy of the dictionary is used. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
34a5bef9-1910-4946-bd35-6f5208f72dd5 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 32,028 | supabase-export-v2 | 292fdd6a4595b410 | test the files using :func:`testfile` or :func:`DocFileSuite`. This is recommended, although is easiest to do for new projects, designed from the start to use doctest.
* Define functions named ``_regrtest_topic`` that consist of single docstrings,
containing test cases for the named topics. These functions can be incl... | trusted_official_docs | CPython Docs | test the files using :func:`testfile` or :func:`DocFileSuite`. This is recommended, although is easiest to do for new projects, designed from the start to use doctest.
* Define functions named ``_regrtest_topic`` that consist of single docstrings,
containing test cases for the named topics. These functions can be incl... | test the files using :func:`testfile` or :func:`DocFileSuite`. This is recommended, although is easiest to do for new projects, designed from the start to use doctest.
* Define functions named ``_regrtest_topic`` that consist of single docstrings,
containing test cases for the named topics. These functions can be incl... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
34b60ba8-c119-4d83-a0f2-11ace52d0854 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 32,026 | supabase-export-v2 | a9dee259c086bb3a | functions that test isolated bits of functionality seemingly at random. It's a different attitude, and produces different results, blurring the distinction between testing and explaining.
Regression testing is best confined to dedicated objects or files. There are
several options for organizing tests: | trusted_official_docs | CPython Docs | functions that test isolated bits of functionality seemingly at random. It's a different attitude, and produces different results, blurring the distinction between testing and explaining.
Regression testing is best confined to dedicated objects or files. There are
several options for organizing tests: | functions that test isolated bits of functionality seemingly at random. It's a different attitude, and produces different results, blurring the distinction between testing and explaining.
Regression testing is best confined to dedicated objects or files. There are
several options for organizing tests: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
355f64c7-194a-41eb-986c-22ebc3ed8375 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,550 | supabase-export-v2 | bc25e3f2a86eebba | $ python example.py $
There's no output! That's normal, and it means all the examples worked. Pass
``-v`` to the script, and :mod:`!doctest` prints a detailed log of what
it's trying, and prints a summary at the end: | trusted_official_docs | CPython Docs | $ python example.py $
There's no output! That's normal, and it means all the examples worked. Pass
``-v`` to the script, and :mod:`!doctest` prints a detailed log of what
it's trying, and prints a summary at the end: | $ python example.py $
There's no output! That's normal, and it means all the examples worked. Pass
``-v`` to the script, and :mod:`!doctest` prints a detailed log of what
it's trying, and prints a summary at the end: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
37327e52-effb-4444-bc34-18613a8efecf | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 32,029 | supabase-export-v2 | 7ce4ab6cfe315f97 | cases for the named topics. These functions can be included in the same file as the module, or separated out into a separate test file.
* Define a :attr:`~module.__test__` dictionary mapping from regression test topics to
docstrings containing test cases. | trusted_official_docs | CPython Docs | cases for the named topics. These functions can be included in the same file as the module, or separated out into a separate test file.
* Define a :attr:`~module.__test__` dictionary mapping from regression test topics to
docstrings containing test cases. | cases for the named topics. These functions can be included in the same file as the module, or separated out into a separate test file.
* Define a :attr:`~module.__test__` dictionary mapping from regression test topics to
docstrings containing test cases. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3a3c0aaa-ee5c-4ebb-a40b-ba508c9c3462 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,574 | supabase-export-v2 | 10c2d060f3916d39 | Simple Usage: Checking Examples in a Text File ----------------------------------------------
Another simple application of doctest is testing interactive examples in a text
file. This can be done with the :func:`testfile` function:: | trusted_official_docs | CPython Docs | Simple Usage: Checking Examples in a Text File ----------------------------------------------
Another simple application of doctest is testing interactive examples in a text
file. This can be done with the :func:`testfile` function:: | Simple Usage: Checking Examples in a Text File ----------------------------------------------
Another simple application of doctest is testing interactive examples in a text
file. This can be done with the :func:`testfile` function:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3d3d77b0-e66a-4777-ba0b-3790ed0f3c16 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,819 | supabase-export-v2 | 730798696d41ec26 | Optional arguments *setUp*, *tearDown*, and *optionflags* are the same as for function :func:`DocFileSuite` above, but they are called for each docstring.
This function uses the same search technique as :func:`testmod`. | trusted_official_docs | CPython Docs | Optional arguments *setUp*, *tearDown*, and *optionflags* are the same as for function :func:`DocFileSuite` above, but they are called for each docstring.
This function uses the same search technique as :func:`testmod`. | Optional arguments *setUp*, *tearDown*, and *optionflags* are the same as for function :func:`DocFileSuite` above, but they are called for each docstring.
This function uses the same search technique as :func:`testmod`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3dac8052-e78a-4302-9eec-43f5c25f9955 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,768 | supabase-export-v2 | ae20cc479aa0014e | prints nothing at the end. In verbose mode, the summary is detailed, else the summary is very brief (in fact, empty if all tests passed).
Optional argument *optionflags* (default value ``0``) takes the
:ref:`bitwise OR <bitwise>` of option flags. See section :ref:`doctest-options`. | trusted_official_docs | CPython Docs | prints nothing at the end. In verbose mode, the summary is detailed, else the summary is very brief (in fact, empty if all tests passed).
Optional argument *optionflags* (default value ``0``) takes the
:ref:`bitwise OR <bitwise>` of option flags. See section :ref:`doctest-options`. | prints nothing at the end. In verbose mode, the summary is detailed, else the summary is very brief (in fact, empty if all tests passed).
Optional argument *optionflags* (default value ``0``) takes the
:ref:`bitwise OR <bitwise>` of option flags. See section :ref:`doctest-options`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3f91091c-d033-4e25-905d-f891ed2a0f24 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,647 | supabase-export-v2 | 17a3e3b24341f70a | What About Exceptions? ^^^^^^^^^^^^^^^^^^^^^^
No problem, provided that the traceback is the only output produced by the
example: just paste in the traceback. [#]_ Since tracebacks contain details
that are likely to change rapidly (for example, exact file paths and line
numbers), this is one case where doctest works ha... | trusted_official_docs | CPython Docs | What About Exceptions? ^^^^^^^^^^^^^^^^^^^^^^
No problem, provided that the traceback is the only output produced by the
example: just paste in the traceback. [#]_ Since tracebacks contain details
that are likely to change rapidly (for example, exact file paths and line
numbers), this is one case where doctest works ha... | What About Exceptions? ^^^^^^^^^^^^^^^^^^^^^^
No problem, provided that the traceback is the only output produced by the
example: just paste in the traceback. [#]_ Since tracebacks contain details
that are likely to change rapidly (for example, exact file paths and line
numbers), this is one case where doctest works ha... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3fef1119-fc5a-455c-aa46-268ed4543c61 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,814 | supabase-export-v2 | 45e10c77600b0433 | and a (sometimes approximate) line number. If all the examples in a docstring are skipped, then the synthesized unit test is also marked as skipped.
Optional argument *module* provides the module to be tested. It can be a module
object or a (possibly dotted) module name. If not specified, the module calling
this func... | trusted_official_docs | CPython Docs | and a (sometimes approximate) line number. If all the examples in a docstring are skipped, then the synthesized unit test is also marked as skipped.
Optional argument *module* provides the module to be tested. It can be a module
object or a (possibly dotted) module name. If not specified, the module calling
this func... | and a (sometimes approximate) line number. If all the examples in a docstring are skipped, then the synthesized unit test is also marked as skipped.
Optional argument *module* provides the module to be tested. It can be a module
object or a (possibly dotted) module name. If not specified, the module calling
this func... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
405d9035-2f15-4a65-bc99-6d6a7d456196 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,969 | supabase-export-v2 | 28a04ae6ecabe21e | Then an interactive Python session may look like this::
>>> import a, doctest
>>> doctest.testmod(a)
--Return--
> <doctest a[1]>(3)g()->None
-> import pdb; pdb.set_trace()
(Pdb) list
1 def g(x):
2 print(x+3)
3 -> import pdb; pdb.set_trace()
[EOF]
(Pdb) p x
6
(Pdb) step
--Return--
> <doctest a[0]>(2)f()->N... | trusted_official_docs | CPython Docs | Then an interactive Python session may look like this::
>>> import a, doctest
>>> doctest.testmod(a)
--Return--
> <doctest a[1]>(3)g()->None
-> import pdb; pdb.set_trace()
(Pdb) list
1 def g(x):
2 print(x+3)
3 -> import pdb; pdb.set_trace()
[EOF]
(Pdb) p x
6
(Pdb) step
--Return--
> <doctest a[0]>(2)f()->N... | Then an interactive Python session may look like this::
>>> import a, doctest
>>> doctest.testmod(a)
--Return--
> <doctest a[1]>(3)g()->None
-> import pdb; pdb.set_trace()
(Pdb) list
1 def g(x):
2 print(x+3)
3 -> import pdb; pdb.set_trace()
[EOF]
(Pdb) p x
6
(Pdb) step
--Return--
> <doctest a[0]>(2)f()->N... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
42754486-92f4-41aa-b4ed-1a74705d5e24 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,655 | supabase-export-v2 | e726e2de0d5d0673 | type and detail. This is usually the last line of a traceback, but can extend across multiple lines if the exception has a multi-line detail::
>>> raise ValueError('multi\n line\ndetail')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: multi
line
detail | trusted_official_docs | CPython Docs | type and detail. This is usually the last line of a traceback, but can extend across multiple lines if the exception has a multi-line detail::
>>> raise ValueError('multi\n line\ndetail')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: multi
line
detail | type and detail. This is usually the last line of a traceback, but can extend across multiple lines if the exception has a multi-line detail::
>>> raise ValueError('multi\n line\ndetail')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: multi
line
detail | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4382f640-82fe-4acf-aed7-138a1ee24e82 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,716 | supabase-export-v2 | 030a6ad079b53108 | directives may be used to modify the :ref:`option flags <doctest-options>` for an individual example. Doctest directives are special Python comments following an example's source code:
.. productionlist:: doctest
directive: "#" "doctest:" `directive_options`
directive_options: `directive_option` ("," `directive_optio... | trusted_official_docs | CPython Docs | directives may be used to modify the :ref:`option flags <doctest-options>` for an individual example. Doctest directives are special Python comments following an example's source code:
.. productionlist:: doctest
directive: "#" "doctest:" `directive_options`
directive_options: `directive_option` ("," `directive_optio... | directives may be used to modify the :ref:`option flags <doctest-options>` for an individual example. Doctest directives are special Python comments following an example's source code:
.. productionlist:: doctest
directive: "#" "doctest:" `directive_options`
directive_options: `directive_option` ("," `directive_optio... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
44eec730-17f7-4819-a1d7-d89a0fb6820d | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,598 | supabase-export-v2 | be843b35b93c6e60 | :func:`testmod` on it. Note that this may not work correctly if the file is part of a package and imports other submodules from that package.
If the file name does not end with :file:`.py`, :mod:`!doctest` infers
that it must be run with :func:`testfile` instead:: | trusted_official_docs | CPython Docs | :func:`testmod` on it. Note that this may not work correctly if the file is part of a package and imports other submodules from that package.
If the file name does not end with :file:`.py`, :mod:`!doctest` infers
that it must be run with :func:`testfile` instead:: | :func:`testmod` on it. Note that this may not work correctly if the file is part of a package and imports other submodules from that package.
If the file name does not end with :file:`.py`, :mod:`!doctest` infers
that it must be run with :func:`testfile` instead:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
461c599a-f9af-4f1d-8659-cb17fcef4d4f | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 32,022 | supabase-export-v2 | 9412d252681fae1b | #. Executable documentation / literate testing.
These uses have different requirements, and it is important to distinguish them. In particular, filling your docstrings with obscure test cases makes for bad
documentation. | trusted_official_docs | CPython Docs | #. Executable documentation / literate testing.
These uses have different requirements, and it is important to distinguish them. In particular, filling your docstrings with obscure test cases makes for bad
documentation. | #. Executable documentation / literate testing.
These uses have different requirements, and it is important to distinguish them. In particular, filling your docstrings with obscure test cases makes for bad
documentation. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4705aafa-a717-43d9-a6b8-49e2346c2b72 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,606 | supabase-export-v2 | 55724053bb59579f | How It Works ------------
This section examines in detail how doctest works: which docstrings it looks at,
how it finds interactive examples, what execution context it uses, how it
handles exceptions, and how option flags can be used to control its behavior. This is the information that you need to know to write doctes... | trusted_official_docs | CPython Docs | How It Works ------------
This section examines in detail how doctest works: which docstrings it looks at,
how it finds interactive examples, what execution context it uses, how it
handles exceptions, and how option flags can be used to control its behavior. This is the information that you need to know to write doctes... | How It Works ------------
This section examines in detail how doctest works: which docstrings it looks at,
how it finds interactive examples, what execution context it uses, how it
handles exceptions, and how option flags can be used to control its behavior. This is the information that you need to know to write doctes... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
489a3639-12a2-4220-83b5-1a17f8576bc9 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 32,025 | supabase-export-v2 | 6cb3abc2ce3bd73d | the natural attitude when writing a doctest-based test is that you want to explain the fine points of your software, and illustrate them with examples.
This in turn naturally leads to test files that start with the simplest
features, and logically progress to complications and edge cases. A coherent
narrative is the re... | trusted_official_docs | CPython Docs | the natural attitude when writing a doctest-based test is that you want to explain the fine points of your software, and illustrate them with examples.
This in turn naturally leads to test files that start with the simplest
features, and logically progress to complications and edge cases. A coherent
narrative is the re... | the natural attitude when writing a doctest-based test is that you want to explain the fine points of your software, and illustrate them with examples.
This in turn naturally leads to test files that start with the simplest
features, and logically progress to complications and edge cases. A coherent
narrative is the re... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
499bbdbe-cce2-4a30-ad85-706939d62c09 | CPython Docs | file://datasets/cpython/Doc/library/doctest.rst | unknown | 9dfc0366-85b7-4875-8297-1456569ff54b | 31,656 | supabase-export-v2 | b4153c70b539e7f2 | >>> raise ValueError('multi\n line\ndetail') Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: multi line detail
The last three lines (starting with :exc:`ValueError`) are compared against the
exception's type and detail, and the rest are ignored. | trusted_official_docs | CPython Docs | >>> raise ValueError('multi\n line\ndetail') Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: multi line detail
The last three lines (starting with :exc:`ValueError`) are compared against the
exception's type and detail, and the rest are ignored. | >>> raise ValueError('multi\n line\ndetail') Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: multi line detail
The last three lines (starting with :exc:`ValueError`) are compared against the
exception's type and detail, and the rest are ignored. | python, official-docs, cpython, P0 | Local_Trusted_Corpus |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.