repo_id stringclasses 400
values | commit_sha stringclasses 400
values | commit_index int32 0 951 | in_repo_split stringclasses 1
value | cross_repo_split stringclasses 1
value | test_file stringlengths 7 121 | test_function stringlengths 1 108 | assertion_type stringclasses 32
values | difficulty stringclasses 8
values | context_lines int32 3 600 | prefix large_stringlengths 44 113k | target large_stringlengths 1 498 | anchor_sha stringclasses 400
values | anchor_index int32 0 951 | qna_source stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a40_api/test_api_cave.py | test_api_cave_tuple_nonetypeor | assert | collection | 129 | import argparse, functools, re, sys, weakref
from beartype_test._util.mark.pytskip import skip_if_pypy, skip_unless_package
from collections import deque
from collections.abc import Iterable
from decimal import Decimal
from enum import Enum
from fractions import Fraction
def _we_were_dreamers_dreaming_greatly_in_the_m... | (NoneType,) | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/error/test_utilerrwarn.py | test_reissue_warnings_placeholder | assert | collection | 124 | def test_reissue_warnings_placeholder() -> None:
'''
Test the
:func:`beartype._util.error.utilerrwarn.reissue_warnings_placeholder`
function.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype._util.error.utilerr... | (0xBEEFDEAD,) | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/api/standard/test_utilapifunctools.py | test_is_func_functools_lru_cache | assert | bool_literal | 17 | def test_is_func_functools_lru_cache() -> None:
'''
Test the
:func:`beartype._util.api.standard.utilfunctools.is_func_functools_lru_cache`
tester.
'''
# Defer test-specific imports.
from beartype._util.api.standard.utilfunctools import is_func_functools_lru_cache
from beartype_test.a00_... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/api/test_utilapibeartype.py | test_is_func_beartyped | assert | bool_literal | 32 | def test_is_func_beartyped() -> None:
'''
Test the
:func:`beartype._util.api.utilbeartype.is_func_beartyped` tester.
'''
# Defer test-specific imports.
from beartype import beartype
from beartype._util.api.utilbeartype import is_func_beartyped
@beartype
def where_that_or() -> str:
... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/cls/pep/test_utilpep557.py | test_is_type_pep557 | assert | bool_literal | 26 | def test_is_type_pep557() -> None:
'''
Test the
:func:`beartype._util.cls.pep.utilpep557.is_type_pep557` tester.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype.roar._roarexc import _BeartypeUtilTypeException
... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/cls/test_utilclstest.py | test_is_type_or_types | assert | bool_literal | 11 | def test_is_type_or_types() -> None:
'''
Test the :func:`beartype._util.cls.utilclstest.is_type_or_types` tester.
'''
# Defer test-specific imports.
from beartype._util.cls.utilclstest import is_type_or_types
# Assert this tester accepts an arbitrary type.
assert is_type_or_types(str) is | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/func/arg/test_utilfuncargtest.py | test_is_func_argless | assert | bool_literal | 20 | def test_is_func_argless() -> None:
'''
Test the
:func:`beartype._util.func.arg.utilfuncargtest.is_func_argless` tester.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype._util.func.arg.utilfuncargtest import is_fun... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/func/pep/test_utilpep484func.py | test_is_func_pep484_notypechecked | assert | bool_literal | 32 | def test_is_func_pep484_notypechecked() -> None:
'''
Test the
:func:`beartype._util.func.pep.utilpep484func.is_func_pep484_notypechecked`
tester.
'''
# Defer test-specific imports.
from beartype._util.func.pep.utilpep484func import (
is_func_pep484_notypechecked)
from typing imp... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/func/test_utilfuncfile.py | test_is_func_file | assert | bool_literal | 20 | def test_is_func_file() -> None:
'''
Test the
:func:`beartype._util.func.utilfuncfile.is_func_file` tester.
'''
# Defer test-specific imports.
from beartype._util.func.utilfuncfile import is_func_file
# Arbitrary pure-Python callable declared on-disk.
def but_now_thy_youngest_dearest_o... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/func/test_utilfuncframe.py | test_get_frame | assert | bool_literal | 12 | def test_get_frame() -> None:
'''
Test the
:func:`beartype._util.func.utilfuncframe.get_frame` getter.
'''
# Defer test-specific imports.
from beartype._util.func.utilfuncframe import get_frame
# Assert this attribute is a callable under both CPython and PyPy.
assert callable(get_fram... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/func/test_utilfuncscope.py | test_is_func_nested | assert | bool_literal | 103 | def attach_func_locals(**kwargs) -> 'collections.abc.Callable':
'''
Decorator attaching the local scope of the parent callable declaring the
passed callable to a new ``func_locals`` attribute of the passed callable.
Parameters
----------
This decorator forwards all passed keyword parameters as ... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/func/test_utilfunctest.py | test_is_func_lambda | assert | bool_literal | 14 | def test_is_func_lambda() -> None:
'''
Test the
:func:`beartype._util.func.utilfunctest.is_func_lambda` tester.
'''
# Defer test-specific imports.
from beartype._util.func.utilfunctest import is_func_lambda
def intimations_of_immortality(): 'from Recollections of Early Childhood'
# As... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/hint/a00_pep/proposal/pep484585/test_utilpep484585.py | test_is_hint_pep484585_tuple_empty | assert | bool_literal | 17 | def test_is_hint_pep484585_tuple_empty() -> None:
'''
Test the
:func:`beartype._util.hint.pep.proposal.pep484585.pep484585tuple.is_hint_pep484585_tuple_empty`
tester.
'''
# Defer test-specific imports.
from beartype._util.hint.pep.proposal.pep484585.pep484585tuple import (
is_hint_p... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/hint/a00_pep/proposal/test_utilpep484604.py | test_is_hint_pep604 | assert | bool_literal | 16 | def test_is_hint_pep604() -> None:
'''
Test the private
:mod:`beartype._util.hint.pep.proposal.pep484604.is_hint_pep604` tester.
'''
# Defer test-specific imports.
from beartype._util.hint.pep.proposal.pep484604 import is_hint_pep604
from beartype._util.py.utilpyversion import IS_PYTHON_AT_... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/hint/a00_pep/proposal/test_utilpep544.py | test_is_hint_pep544_protocol | assert | bool_literal | 88 | def test_is_hint_pep544_protocol() -> None:
'''
Test the private
:mod:`beartype._util.hint.pep.proposal.pep544.is_hint_pep544_protocol`
tester.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from abc import abstractmethod
... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/hint/a00_pep/proposal/test_utilpep589.py | test_is_hint_pep589 | assert | bool_literal | 54 | def test_is_hint_pep589() -> None:
'''
Test the
:beartype._util.hint.pep.proposal.pep589.is_hint_pep589` tester.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype._util.hint.pep.proposal.pep589 import is_hint_pep589... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/hint/a00_pep/test_a90_utilpeptest.py | test_is_hint_pep | assert | bool_literal | 23 | def test_is_hint_pep(hints_pep_meta, hints_nonpep_meta) -> None:
'''
Test the :func:`beartype._util.hint.pep.utilpeptest.is_hint_pep`
tester.
Parameters
----------
hints_pep_meta : List[beartype_test.a00_unit.data.hint.util.data_hintmetacls.HintPepMetadata]
List of PEP-compliant type hi... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/hint/a10_nonpep/test_utilhintnonpeptest.py | test_is_hint_nonpep | assert | bool_literal | 26 | def test_is_hint_nonpep(not_hints_nonpep) -> None:
'''
Test the
:func:`beartype._util.hint.nonpep.utilnonpeptest.is_hint_nonpep`
tester.
Parameters
----------
not_hints_nonpep : frozenset
Frozen set of various objects that are *not* PEP-noncompliant type hints
exercising wel... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/hint/a90_core/test_utilhinttest.py | test_is_hint | assert | bool_literal | 22 | def test_is_hint(hints_pep_meta) -> None:
'''
Test the :func:`beartype._util.hint.utilhinttest.is_hint` tester.
Parameters
----------
hints_pep_meta : List[beartype_test.a00_unit.data.hint.util.data_hintmetacls.HintPepMetadata]
List of type hint metadata describing sample type hints exercis... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/kind/map/test_utilmaptest.py | test_is_mapping_keys_all | assert | bool_literal | 18 | def test_is_mapping_keys_all() -> None:
'''
Test the
:func:`beartype._util.kind.map.utilmaptest.is_mapping_keys_all` tester.
'''
# Defer test-specific imports.
from beartype.roar._roarexc import _BeartypeUtilMappingException
from beartype._util.kind.map.utilmaptest import is_mapping_keys_al... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/module/test_utilmodtest.py | test_is_module | assert | bool_literal | 14 | def test_is_module() -> None:
'''
Test the :func:`beartype._util.module.utilmodtest.is_module` tester.
'''
# Defer test-specific imports.
from beartype.roar import BeartypeModuleUnimportableWarning
from beartype._util.module.utilmodtest import is_module
from pytest import warns
# Asser... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/py/test_utilpyinterpreter.py | test_is_python_optimized | assert | bool_literal | 35 | def test_is_python_optimized(monkeypatch: 'pytest.MonkeyPatch') -> None:
'''
Test the :func:`beartype._util.py.utilpyinterpreter.is_python_optimized`
tester.
Parameters
----------
monkeypatch : MonkeyPatch
:mod:`pytest` fixture allowing various state associated with the active
P... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/test_utilobject.py | test_is_object_hashable | assert | bool_literal | 14 | def test_is_object_hashable() -> None:
'''
Test the :func:`beartype._util.utilobject.is_object_hashable` tester.
'''
# Defer test-specific imports.
from beartype._util.utilobject import is_object_hashable
from beartype_test.a00_unit.data.hint.data_hint import (
NOT_HINTS_HASHABLE, NOT_H... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/text/test_utiltextansi.py | test_is_text_ansi | assert | bool_literal | 14 | def test_is_text_ansi() -> None:
'''
Test the :func:`beartype._util.text.utiltextansi.is_str_ansi` tester.
'''
# Defer test-specific imports.
from beartype._util.text.utiltextansi import is_str_ansi
# Assert that this tester returns false for a string containing *NO* ANSI.
assert is_str_an... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a20_util/text/test_utiltextidentifier.py | test_is_identifier | assert | bool_literal | 12 | def test_is_identifier() -> None:
'''
Test the :func:`beartype._util.text.utiltextidentifier.is_identifier` tester.
'''
# Defer test-specific imports.
from beartype._util.text.utiltextidentifier import is_identifier
# Assert this tester accepts an unqualified Python identifier prefixed by
... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a40_api/conf/test_confcls.py | test_conf_dataclass | assert | bool_literal | 155 | def test_conf_dataclass() -> None:
'''
Test the public :func:`beartype.BeartypeConf` class.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype import (
BeartypeConf,
BeartypeDecorationPosition,
Be... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a40_api/door/a00_type/test_door_typehint.py | test_door_typehint_bool | assert | bool_literal | 18 | from beartype_test._util.mark.pytmark import ignore_warnings
def test_door_typehint_bool() -> None:
'''
Test the :meth:`beartype.door.TypeHint.__len__` dunder method.
'''
# Defer test-specific imports.
from beartype.door import TypeHint
from beartype.typing import (
Tuple,
Unio... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/beartype | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | train | train | beartype_test/a00_unit/a40_api/vale/_is/test_valeis.py | test_api_vale_is_pass | assert | bool_literal | 96 | def test_api_vale_is_pass() -> None:
'''
Test successful usage of the :mod:`beartype.vale.Is` factory.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype import beartype
from beartype._util.func.utilfuncmake import m... | True | c92e73705cfe484b2e78a1e8e6ec8d835e9c294e | 727 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_advanced.py | test_keywords | assert | numeric_literal | 19 | import collections
import math
import operator
from functools import wraps
from typing import Union
import pytest
from plum import Dispatcher, Function, NotFoundLookupError
def test_keywords():
dispatch = Dispatcher()
@dispatch
def f(x: int, *, option=None):
return x
assert f(2) == | 2 | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_advanced.py | test_defaults | assert | numeric_literal | 27 | import collections
import math
import operator
from functools import wraps
from typing import Union
import pytest
from plum import Dispatcher, Function, NotFoundLookupError
def test_defaults():
dispatch = Dispatcher()
y_default = 3
@dispatch
def f(x: int, y: int = y_default, *, option=None):
... | 4 | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_advanced.py | test_metadata_and_printing | assert | string_literal | 24 | import collections
import math
import operator
from functools import wraps
from typing import Union
import pytest
from plum import Dispatcher, Function, NotFoundLookupError
def test_metadata_and_printing():
dispatch = Dispatcher()
class A:
@dispatch
def g(self):
"""Docs of g"""
... | "f" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_advanced.py | test_metadata_and_printing | assert | string_literal | 35 | import collections
import math
import operator
from functools import wraps
from typing import Union
import pytest
from plum import Dispatcher, Function, NotFoundLookupError
def test_metadata_and_printing():
dispatch = Dispatcher()
class A:
@dispatch
def g(self):
"""Docs of g"""
... | "g" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_advanced.py | test_strange_functions | assert | variable | 23 | import collections
import math
import operator
from functools import wraps
from typing import Union
import pytest
from plum import Dispatcher, Function, NotFoundLookupError
@pytest.mark.parametrize(
"f, x, res",
[
(operator.attrgetter("x"), collections.namedtuple("NamedTuple", "x")(x=1), 1),
... | res | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_advanced.py | test_defaults | assert | complex_expr | 32 | import collections
import math
import operator
from functools import wraps
from typing import Union
import pytest
from plum import Dispatcher, Function, NotFoundLookupError
def test_defaults():
dispatch = Dispatcher()
y_default = 3
@dispatch
def f(x: int, y: int = y_default, *, option=None):
... | 4**2 | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_advanced.py | test_none | assert | none_literal | 26 | import collections
import math
import operator
from functools import wraps
from typing import Union
import pytest
from plum import Dispatcher, Function, NotFoundLookupError
def dec(f):
@wraps(f)
def f_wrapped(*args, **kw_args):
return f(*args, **kw_args)
return f_wrapped
def test_none():
di... | None | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_advanced.py | test_invoke | assert | string_literal | 32 | import collections
import math
import operator
from functools import wraps
from typing import Union
import pytest
from plum import Dispatcher, Function, NotFoundLookupError
def test_invoke():
dispatch = Dispatcher()
@dispatch()
def f():
return "fallback"
@dispatch
def f(x: int):
... | "int" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_advanced.py | test_invoke | assert | string_literal | 33 | import collections
import math
import operator
from functools import wraps
from typing import Union
import pytest
from plum import Dispatcher, Function, NotFoundLookupError
def test_invoke():
dispatch = Dispatcher()
@dispatch()
def f():
return "fallback"
@dispatch
def f(x: int):
... | "str" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_annotated.py | test_simple_annotated | assert | numeric_literal | 17 | import pytest
from beartype.vale import Is
from plum import Dispatcher, NotFoundLookupError
from plum.typing import Annotated
def test_simple_annotated():
dispatch = Dispatcher()
positive_int = Annotated[int, Is[lambda value: value > 0]]
@dispatch
def f(x: positive_int):
return x
asser... | 1 | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_annotated.py | test_simple_annotated | pytest.raises | variable | 19 | import pytest
from beartype.vale import Is
from plum import Dispatcher, NotFoundLookupError
from plum.typing import Annotated
def test_simple_annotated():
dispatch = Dispatcher()
positive_int = Annotated[int, Is[lambda value: value > 0]]
@dispatch
def f(x: positive_int):
return x
assert... | NotFoundLookupError) | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_cases.py | test_inheritance | assert | string_literal | 30 | import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def test_inheritance():
device = Device()
calc = Calculator(1)
hammer = Hammer()
assert device + calc == "unknown device"
assert Device.__add__(device, ... | "result" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_cases.py | test_varargs | assert | string_literal | 35 | import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def f(a: Num):
return "number"
def f(a: Num, b: Num):
return "two numbers"
def f(a: Num, b: Rat):
return "a number and a float"
def f(a: Num, b: Num, *cs: Num... | "number" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_cases.py | test_inheritance | assert | string_literal | 31 | import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def test_inheritance():
device = Device()
calc = Calculator(1)
hammer = Hammer()
assert device + calc == "unknown device"
assert Device.__add__(device, ... | "a result" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_cases.py | test_varargs | assert | string_literal | 34 | import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def f(a: Num):
return "number"
def f(a: Num, b: Num):
return "two numbers"
def f(a: Num, b: Rat):
return "a number and a float"
def f(a: Num, b: Num, *cs: Num... | "fallback" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_cases.py | test_varargs | pytest.raises | variable | 40 | import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def f(a: Num):
return "number"
def f(a: Num, b: Num):
return "two numbers"
def f(a: Num, b: Rat):
return "a number and a float"
def f(a: Num, b: Num, *cs: Num... | LookupError) | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_cases.py | test_inheritance | assert | string_literal | 22 | import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def test_inheritance():
device = Device()
calc = Calculator(1)
hammer = Hammer()
assert device + calc == "unknown device"
assert Device.__add__(device, ... | "super hammer" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_cases.py | test_method_dispatch | assert | string_literal | 12 | import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def test_method_dispatch():
device = Device()
assert device.do() == | "doing nothing" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_cases.py | test_method_dispatch | assert | string_literal | 16 | import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def test_method_dispatch():
device = Device()
assert device.do() == "doing nothing"
assert device.do(Rat(), Rat()) == "doing a real and a number"
assert dev... | "doing a device" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_cases.py | test_inheritance | assert | string_literal | 14 | import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def test_inheritance():
device = Device()
calc = Calculator(1)
hammer = Hammer()
assert device + calc == | "unknown device" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_cases.py | test_inheritance_exceptions | assert | string_literal | 25 | import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def test_inheritance_exceptions():
calc = Calculator()
o = ComputableObject()
# Test instantiation.
with pytest.raises(NotFoundLookupError):
Calcula... | "another result" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_cases.py | test_method_dispatch | assert | string_literal | 15 | import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def test_method_dispatch():
device = Device()
assert device.do() == "doing nothing"
assert device.do(Rat(), Rat()) == "doing a real and a number"
assert dev... | "doing two numbers" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_cases.py | test_inheritance_exceptions | pytest.raises | variable | 14 | import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def test_inheritance_exceptions():
calc = Calculator()
o = ComputableObject()
# Test instantiation.
with pytest.raises( | NotFoundLookupError) | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_cases.py | test_inheritance_exceptions | pytest.raises | variable | 22 | import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def test_inheritance_exceptions():
calc = Calculator()
o = ComputableObject()
# Test instantiation.
with pytest.raises(NotFoundLookupError):
Calcula... | AmbiguousLookupError) | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_cases.py | test_method_dispatch | assert | string_literal | 13 | import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def test_method_dispatch():
device = Device()
assert device.do() == "doing nothing"
assert device.do(Rat(), Rat()) == | "doing a real and a number" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_correctness.py | test_none | assert | none_literal | 49 | from functools import wraps
import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def f(a: Num):
return "number"
def f(a: Num, b: Num):
return "two numbers"
def f(a: Num, b: Rat):
return "a number and a float"
d... | None | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_correctness.py | test_self_reference | assert | string_literal | 39 | from functools import wraps
import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def f(a: Num):
return "number"
def f(a: Num, b: Num):
return "two numbers"
def f(a: Num, b: Rat):
return "a number and a float"
d... | "str" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_correctness.py | test_decorator | assert | string_literal | 57 | from functools import wraps
import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def f(a: Num):
return "number"
def f(a: Num, b: Num):
return "two numbers"
def f(a: Num, b: Rat):
return "a number and a float"
d... | "int" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_correctness.py | test_self_reference | assert | string_literal | 38 | from functools import wraps
import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def f(a: Num):
return "number"
def f(a: Num, b: Num):
return "two numbers"
def f(a: Num, b: Rat):
return "a number and a float"
d... | "self" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_correctness.py | test_nested_class | assert | string_literal | 39 | from functools import wraps
import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def f(a: Num):
return "number"
def f(a: Num, b: Num):
return "two numbers"
def f(a: Num, b: Rat):
return "a number and a float"
d... | "int1" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_correctness.py | test_nested_class | assert | string_literal | 40 | from functools import wraps
import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def f(a: Num):
return "number"
def f(a: Num, b: Num):
return "two numbers"
def f(a: Num, b: Rat):
return "a number and a float"
d... | "str1" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_correctness.py | test_nested_class | assert | string_literal | 42 | from functools import wraps
import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def f(a: Num):
return "number"
def f(a: Num, b: Num):
return "two numbers"
def f(a: Num, b: Rat):
return "a number and a float"
d... | "int2" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_correctness.py | test_nested_class | assert | string_literal | 43 | from functools import wraps
import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def f(a: Num):
return "number"
def f(a: Num, b: Num):
return "two numbers"
def f(a: Num, b: Rat):
return "a number and a float"
d... | "str2" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_correctness.py | test_property | assert | string_literal | 45 | from functools import wraps
import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def f(a: Num):
return "number"
def f(a: Num, b: Num):
return "two numbers"
def f(a: Num, b: Rat):
return "a number and a float"
d... | "name" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_correctness.py | test_inheritance | assert | string_literal | 32 | from functools import wraps
import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def test_inheritance():
device = Device()
calc = Calculator(1)
hammer = Hammer()
assert device + calc == "unknown device"
a... | "result" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_correctness.py | test_varargs | assert | string_literal | 37 | from functools import wraps
import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def f(a: Num):
return "number"
def f(a: Num, b: Num):
return "two numbers"
def f(a: Num, b: Rat):
return "a number and a float"
d... | "number" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_correctness.py | test_inheritance | assert | string_literal | 33 | from functools import wraps
import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def test_inheritance():
device = Device()
calc = Calculator(1)
hammer = Hammer()
assert device + calc == "unknown device"
a... | "a result" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_correctness.py | test_varargs | assert | string_literal | 36 | from functools import wraps
import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def f(a: Num):
return "number"
def f(a: Num, b: Num):
return "two numbers"
def f(a: Num, b: Rat):
return "a number and a float"
d... | "fallback" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_correctness.py | test_varargs | pytest.raises | variable | 42 | from functools import wraps
import pytest
from plum import AmbiguousLookupError, Dispatcher, NotFoundLookupError
from plum.type import PromisedType
dispatch = Dispatcher()
def f(a: Num):
return "number"
def f(a: Num, b: Num):
return "two numbers"
def f(a: Num, b: Rat):
return "a number and a float"
d... | LookupError) | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_future_annotations.py | test_forward_reference | assert | numeric_literal | 18 | from __future__ import annotations
import math
from typing import Union
import pytest
from plum import Dispatcher, NotFoundLookupError
dispatch = Dispatcher()
def test_forward_reference():
one = Number(1)
two = Number(2)
three = one + two
assert isinstance(three, Number)
assert three.value == | 3 | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_future_annotations.py | test_staticmethod | assert | numeric_literal | 17 | from __future__ import annotations
import math
from typing import Union
import pytest
from plum import Dispatcher, NotFoundLookupError
dispatch = Dispatcher()
@pytest.mark.parametrize("one", [Number(1), "1"])
def test_staticmethod(one):
two = Number.add_one(one)
assert isinstance(two, Number)
assert t... | 2 | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_future_annotations.py | test_extension_c | assert | numeric_literal | 20 | from __future__ import annotations
import math
from typing import Union
import pytest
from plum import Dispatcher, NotFoundLookupError
dispatch = Dispatcher()
def test_extension_c():
dispatch = Dispatcher()
@dispatch
def f(x: int):
return x
assert f(1) == | 1 | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_future_annotations.py | test_extension | assert | string_literal | 20 | from __future__ import annotations
import math
from typing import Union
import pytest
from plum import Dispatcher, NotFoundLookupError
dispatch = Dispatcher()
def test_extension():
dispatch = Dispatcher()
@dispatch
def f(x: int):
return "int"
assert f(1) == | "int" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_future_annotations.py | test_extension | assert | string_literal | 30 | from __future__ import annotations
import math
from typing import Union
import pytest
from plum import Dispatcher, NotFoundLookupError
dispatch = Dispatcher()
def test_extension():
dispatch = Dispatcher()
@dispatch
def f(x: int):
return "int"
assert f(1) == "int"
with pytest.raises(No... | "str" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_future_annotations.py | test_forward_reference | pytest.raises | variable | 24 | from __future__ import annotations
import math
from typing import Union
import pytest
from plum import Dispatcher, NotFoundLookupError
dispatch = Dispatcher()
def test_forward_reference():
one = Number(1)
two = Number(2)
three = one + two
assert isinstance(three, Number)
assert three.value == 3... | NotFoundLookupError) | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_precedence.py | test_precedence | assert | variable | 29 | import pytest
from plum import AmbiguousLookupError, Dispatcher
dispatch = Dispatcher()
def mul(a: ZeroElement, b: Element):
# Return zero.
return a
def mul(a: Element, b: SpecialisedElement):
# Perform a specialised operation.
return b
def mul_precedence(a: ZeroElement, b: Element):
# Return z... | ZeroElement | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_precedence.py | test_precedence | assert | variable | 30 | import pytest
from plum import AmbiguousLookupError, Dispatcher
dispatch = Dispatcher()
def mul(a: ZeroElement, b: Element):
# Return zero.
return a
def mul(a: Element, b: SpecialisedElement):
# Perform a specialised operation.
return b
def mul_precedence(a: ZeroElement, b: Element):
# Return z... | SpecialisedElement | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_return_type.py | test_return_type | assert | numeric_literal | 15 | from typing import Union
import pytest
from plum import Dispatcher, add_conversion_method
def test_return_type():
dispatch = Dispatcher()
@dispatch
def f(x: Union[int, str]) -> int:
return x
assert f(1) == | 1 | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_return_type.py | test_inheritance | assert | variable | 12 | from typing import Union
import pytest
from plum import Dispatcher, add_conversion_method
def test_inheritance():
b = B()
assert b.do(1) == 1
assert b.do(b) == | b | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_return_type.py | test_inheritance_self_return | assert | variable | 10 | from typing import Union
import pytest
from plum import Dispatcher, add_conversion_method
def test_inheritance_self_return():
a = A2()
assert a.do(a) is | a | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_return_type.py | test_return_type | pytest.raises | variable | 17 | from typing import Union
import pytest
from plum import Dispatcher, add_conversion_method
def test_return_type():
dispatch = Dispatcher()
@dispatch
def f(x: Union[int, str]) -> int:
return x
assert f(1) == 1
assert f.invoke(int)(1) == 1
with pytest.raises( | TypeError) | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/advanced/test_return_type.py | test_inheritance | assert | string_literal | 15 | from typing import Union
import pytest
from plum import Dispatcher, add_conversion_method
def test_inheritance():
b = B()
assert b.do(1) == 1
assert b.do(b) == b
with pytest.raises(TypeError):
b.do("1")
assert b.do(1.0) == | "hello from A" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/test_alias.py | test_union_alias | assert | string_literal | 27 | from typing import Union
import pytest
from plum import activate_union_aliases, deactivate_union_aliases, set_union_alias
from plum.alias import _aliased_unions
def union_aliases():
"""Activate union aliases during the test and remove all aliases after the test
finishes."""
activate_union_aliases()
y... | "typing.Union[IntStr]" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/test_alias.py | test_optional | assert | string_literal | 18 | from typing import Union
import pytest
from plum import activate_union_aliases, deactivate_union_aliases, set_union_alias
from plum.alias import _aliased_unions
def union_aliases():
"""Activate union aliases during the test and remove all aliases after the test
finishes."""
activate_union_aliases()
y... | "typing.Optional[int]" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/test_alias.py | test_union_alias | assert | string_literal | 37 | from typing import Union
import pytest
from plum import activate_union_aliases, deactivate_union_aliases, set_union_alias
from plum.alias import _aliased_unions
def union_aliases():
"""Activate union aliases during the test and remove all aliases after the test
finishes."""
activate_union_aliases()
y... | "typing.Union[IntStrFloat]" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/test_alias.py | test_double_registration | pytest.raises | complex_expr | 22 | from typing import Union
import pytest
from plum import activate_union_aliases, deactivate_union_aliases, set_union_alias
from plum.alias import _aliased_unions
def union_aliases():
"""Activate union aliases during the test and remove all aliases after the test
finishes."""
activate_union_aliases()
y... | RuntimeError, match=r"already has alias") | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/test_alias.py | test_union_alias | assert | collection | 20 | from typing import Union
import pytest
from plum import activate_union_aliases, deactivate_union_aliases, set_union_alias
from plum.alias import _aliased_unions
def union_aliases():
"""Activate union aliases during the test and remove all aliases after the test
finishes."""
activate_union_aliases()
y... | { "typing.Union[int, str]", "typing.Union[str, int]", } | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/test_autoreload.py | test_autoreload_correctness | assert | numeric_literal | 27 | import pytest
from plum import Dispatcher
from plum import autoreload as ar
from plum.function import NotFoundLookupError
def test_autoreload_correctness():
dispatch = Dispatcher()
class A1:
pass
class A2:
pass
class A3:
pass
@dispatch
def test(x: A1):
retur... | 1 | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/test_autoreload.py | test_autoreload_activate_deactivate | assert | none_literal | 21 | import pytest
from plum import Dispatcher
from plum import autoreload as ar
from plum.function import NotFoundLookupError
def test_autoreload_activate_deactivate():
# We shouldn't be able to deactivate before activation.
with pytest.raises(
RuntimeError,
match=r"(?i)plum autoreload module was ... | None | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/test_autoreload.py | test_autoreload_activate_deactivate | assert | string_literal | 23 | import pytest
from plum import Dispatcher
from plum import autoreload as ar
from plum.function import NotFoundLookupError
def test_autoreload_activate_deactivate():
# We shouldn't be able to deactivate before activation.
with pytest.raises(
RuntimeError,
match=r"(?i)plum autoreload module was ... | "plum.autoreload" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/test_autoreload.py | test_autoreload_activate_deactivate | assert | complex_expr | 30 | import pytest
from plum import Dispatcher
from plum import autoreload as ar
from plum.function import NotFoundLookupError
def test_autoreload_activate_deactivate():
# We shouldn't be able to deactivate before activation.
with pytest.raises(
RuntimeError,
match=r"(?i)plum autoreload module was ... | ar._update_instances_original | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/test_autoreload.py | test_autoreload_activate_deactivate | assert | string_literal | 22 | import pytest
from plum import Dispatcher
from plum import autoreload as ar
from plum.function import NotFoundLookupError
def test_autoreload_activate_deactivate():
# We shouldn't be able to deactivate before activation.
with pytest.raises(
RuntimeError,
match=r"(?i)plum autoreload module was ... | "IPython.extensions.autoreload" | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/test_cache.py | test_cache_function | assert | numeric_literal | 65 | from typing import List, Union
from plum import Dispatcher, Function, clear_all_cache
from .util import benchmark
def assert_cache_performance(f, f_native):
# Time the performance of a native call.
dur_native = benchmark(f_native, (1,), n=250, burn=10)
def resolve_registrations():
for f in Funct... | 1 | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/test_cache.py | test_cache_clearing | assert | numeric_literal | 48 | from typing import List, Union
from plum import Dispatcher, Function, clear_all_cache
from .util import benchmark
def assert_cache_performance(f, f_native):
# Time the performance of a native call.
dur_native = benchmark(f_native, (1,), n=250, burn=10)
def resolve_registrations():
for f in Funct... | 0 | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/test_cache.py | test_cache_clearing | assert | numeric_literal | 54 | from typing import List, Union
from plum import Dispatcher, Function, clear_all_cache
from .util import benchmark
def assert_cache_performance(f, f_native):
# Time the performance of a native call.
dur_native = benchmark(f_native, (1,), n=250, burn=10)
def resolve_registrations():
for f in Funct... | 2 | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/test_cache.py | test_cache_function | assert | none_literal | 59 | from typing import List, Union
from plum import Dispatcher, Function, clear_all_cache
from .util import benchmark
def assert_cache_performance(f, f_native):
# Time the performance of a native call.
dur_native = benchmark(f_native, (1,), n=250, burn=10)
def resolve_registrations():
for f in Funct... | None | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/test_cache.py | test_cache_function | assert_* | variable | 56 | from typing import List, Union
from plum import Dispatcher, Function, clear_all_cache
from .util import benchmark
def assert_cache_performance(f, f_native):
# Time the performance of a native call.
dur_native = benchmark(f_native, (1,), n=250, burn=10)
def resolve_registrations():
for f in Funct... | f_native) | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/test_cache.py | test_cache_class | assert_* | variable | 52 | from typing import List, Union
from plum import Dispatcher, Function, clear_all_cache
from .util import benchmark
def assert_cache_performance(f, f_native):
# Time the performance of a native call.
dur_native = benchmark(f_native, (1,), n=250, burn=10)
def resolve_registrations():
for f in Funct... | a_native) | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/test_cache.py | assert_cache_performance | assert | complex_expr | 32 | from typing import List, Union
from plum import Dispatcher, Function, clear_all_cache
from .util import benchmark
def assert_cache_performance(f, f_native):
# Time the performance of a native call.
dur_native = benchmark(f_native, (1,), n=250, burn=10)
def resolve_registrations():
for f in Funct... | 2000 * dur | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/test_cache.py | assert_cache_performance | assert | complex_expr | 35 | from typing import List, Union
from plum import Dispatcher, Function, clear_all_cache
from .util import benchmark
def assert_cache_performance(f, f_native):
# Time the performance of a native call.
dur_native = benchmark(f_native, (1,), n=250, burn=10)
def resolve_registrations():
for f in Funct... | dur_first / 5 | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/test_cache.py | assert_cache_performance | assert | complex_expr | 29 | from typing import List, Union
from plum import Dispatcher, Function, clear_all_cache
from .util import benchmark
def assert_cache_performance(f, f_native):
# Time the performance of a native call.
dur_native = benchmark(f_native, (1,), n=250, burn=10)
def resolve_registrations():
for f in Funct... | 50 * dur_native | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
beartype/plum | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | train | train | tests/test_cache.py | test_cache_class | assert_* | func_call | 55 | from typing import List, Union
from plum import Dispatcher, Function, clear_all_cache
from .util import benchmark
def assert_cache_performance(f, f_native):
# Time the performance of a native call.
dur_native = benchmark(f_native, (1,), n=250, burn=10)
def resolve_registrations():
for f in Funct... | lambda x: a_native.go(x)) | 488131d9bfb4f6bc6659a88679fb44eb7dfee47d | 111 | v2_extractor_at_anchor |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.