repo_id
stringclasses
409 values
prefix
large_stringlengths
34
36.3k
target
large_stringlengths
1
498
assertion_type
stringclasses
31 values
difficulty
stringclasses
8 values
test_file
stringlengths
10
121
test_function
stringlengths
1
104
test_class
stringlengths
0
51
lineno
int32
2
11.3k
commit_idx
int32
beartype/plum
import pytest import plum dispatch = plum.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): return "two or more numbers" def f(a: Num, b: Num, *cs: Re): return "two numb...
"number"
assert
string_literal
tests/advanced/test_cases.py
test_varargs
194
null
beartype/plum
import plum 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 plum.Function._instances: f._resolve_pending_registrations() def...
dur_first / 4
assert
complex_expr
tests/test_cache.py
assert_cache_performance
32
null
beartype/plum
import sys import textwrap import warnings import pytest import plum from plum._method import Method from plum._resolver import ( MethodRedefinitionWarning, Resolver, _document, _render_function_call, ) @pytest.mark.incompatible_with_mypyc def test_doc(monkeypatch): # Let the `pydoc` documenter s...
"first\n\nsecond\n\nthird"
assert
string_literal
tests/test_resolver.py
test_doc
115
null
beartype/plum
import abc import sys import typing from typing import Literal import pytest from plum._type import ( ModuleType, PromisedType, ResolvableType, _is_hint, is_faithful, resolve_type_hint, type_mapping, ) from plum._util import Callable skip_if_less_than_py310 = pytest.mark.skipif( sys.v...
float
assert
variable
tests/test_type.py
test_type_mapping
141
null
beartype/plum
import pytest import plum dispatch = plum.Dispatcher() def test_inheritance_exceptions(): calc = Calculator() o = ComputableObject() # Test instantiation. with pytest.raises(
plum.NotFoundLookupError)
pytest.raises
complex_expr
tests/advanced/test_cases.py
test_inheritance_exceptions
138
null
beartype/plum
import platform import textwrap from copy import copy import plum from .util import rich_render from plum._method import Method from plum._signature import Signature def test_autodetect_name_return(): def f(x) -> float: return x sig = Signature(int) m = Method(f, sig) assert m.function_name...
"f"
assert
string_literal
tests/test_method.py
test_autodetect_name_return
82
null
beartype/plum
import pytest import plum dispatch = plum.Dispatcher() def test_inheritance_exceptions(): calc = Calculator() o = ComputableObject() # Test instantiation. with pytest.raises(plum.NotFoundLookupError): Calculator("1") # Test method lookup. with pytest.raises(plum.NotFoundLookupError)...
"another result"
assert
string_literal
tests/advanced/test_cases.py
test_inheritance_exceptions
149
null
beartype/plum
import sys import textwrap import warnings import pytest import plum from plum._method import Method from plum._resolver import ( MethodRedefinitionWarning, Resolver, _document, _render_function_call, ) def test_resolve(): class A: pass class B1(A): pass class B2(A): ...
m_a
assert
variable
tests/test_resolver.py
test_resolve
218
null
beartype/plum
import pytest import plum dispatch = plum.Dispatcher() def test_inheritance(): device = Device() calc = Calculator(1) hammer = Hammer() assert device + calc ==
"unknown device"
assert
string_literal
tests/advanced/test_cases.py
test_inheritance
112
null
beartype/plum
import sys from typing import Union import numpy as np import pytest from plum._util import ( Comparable, Missing, get_class, get_context, is_in_class, wrap_lambda, ) from plum.repr import repr_short def test_missing(): # `Missing` cannot be instantiated. with pytest.raises(
TypeError)
pytest.raises
variable
tests/test_util.py
test_missing
30
null
beartype/plum
import builtins import inspect import typing import pytest from rich.text import Text from .util import rich_render from plum.repr import _repr_mimebundle_from_rich_, _safe_getfile, repr_type def test_safe_getfile(monkeypatch): assert _safe_getfile(A) ==
inspect.getfile(A)
assert
func_call
tests/test_repr.py
test_safe_getfile
34
null
beartype/plum
import pytest import plum dispatch = plum.Dispatcher() def test_inheritance(): device = Device() calc = Calculator(1) hammer = Hammer() assert device + calc == "unknown device" assert Device.__add__(device, calc) == "unknown device" assert calc + device == "unknown device" assert Calcula...
"a result"
assert
string_literal
tests/advanced/test_cases.py
test_inheritance
129
null
beartype/plum
import abc import os import textwrap import typing import pytest import plum from plum._function import Function, _convert, _owner_transfer from plum._method import Method from plum._resolver import ( AmbiguousLookupError, NotFoundLookupError, _change_function_name, _unwrap_invoked_methods, ) from plu...
"g"
assert
string_literal
tests/test_function.py
test_change_function_name
35
null
beartype/plum
import pytest import plum from plum._signature import Signature as Sig def test_dispatch_multi(dispatch: plum.Dispatcher): @dispatch def f(x: int): return "int" @dispatch.multi((float,), Sig(str, precedence=1)) def f(x): return "float or str" assert f(1) == "int" assert f(1.0...
ValueError)
pytest.raises
variable
tests/test_dispatcher.py
test_dispatch_multi
72
null
beartype/plum
import pytest import plum dispatch = plum.Dispatcher() def test_inheritance(): device = Device() calc = Calculator(1) hammer = Hammer() assert device + calc == "unknown device" assert Device.__add__(device, calc) == "unknown device" assert calc + device == "unknown device" assert Calcula...
"result"
assert
string_literal
tests/advanced/test_cases.py
test_inheritance
128
null
beartype/plum
import platform import textwrap from copy import copy import plum from .util import rich_render from plum._method import Method from plum._signature import Signature def test_instantiation_copy(): def f(x) -> float: return x def f2(x) -> float: return x sig = Signature(int) m = Meth...
m_equal
assert
variable
tests/test_method.py
test_instantiation_copy
42
null
beartype/plum
import sys import textwrap import warnings import pytest import plum from plum._method import Method from plum._resolver import ( MethodRedefinitionWarning, Resolver, _document, _render_function_call, ) def test_resolve(): class A: pass class B1(A): pass class B2(A): ...
m_b1
assert
variable
tests/test_resolver.py
test_resolve
219
null
beartype/plum
import pytest import plum from plum._signature import Signature as Sig def test_abstract(dispatch: plum.Dispatcher): @dispatch.abstract def f(x): """Docs""" assert f.__doc__ == "Docs" assert f.methods ==
[]
assert
collection
tests/test_dispatcher.py
test_abstract
82
null
beartype/plum
import abc import os import textwrap import typing import pytest import plum from plum._function import Function, _convert, _owner_transfer from plum._method import Method from plum._resolver import ( AmbiguousLookupError, NotFoundLookupError, _change_function_name, _unwrap_invoked_methods, ) from plu...
0
assert
numeric_literal
tests/test_function.py
test_register
331
null
beartype/plum
import collections import math import operator from functools import wraps from typing import Union import pytest import plum def test_keywords(dispatch: plum.Dispatcher): @dispatch def f(x: int, *, option=None): return x assert f(2) ==
2
assert
numeric_literal
tests/advanced/test_advanced.py
test_keywords
17
null
beartype/plum
import abc import os import textwrap import typing import pytest import plum from plum._function import Function, _convert, _owner_transfer from plum._method import Method from plum._resolver import ( AmbiguousLookupError, NotFoundLookupError, _change_function_name, _unwrap_invoked_methods, ) from plu...
"B"
assert
string_literal
tests/test_function.py
test_call_mro
456
null
beartype/plum
import typing import warnings from numbers import Number from typing import Union import pytest import plum from plum import add_conversion_method, add_promotion_rule, conversion_method from plum._promotion import _promotion_rule def test_promote(convert, promote): assert promote() == () assert promote(1) ==...
(1.0,)
assert
collection
tests/test_promotion.py
test_promote
89
null
beartype/plum
import pytest import plum dispatch = plum.Dispatcher() def test_inheritance_exceptions(): calc = Calculator() o = ComputableObject() # Test instantiation. with pytest.raises(plum.NotFoundLookupError): Calculator("1") # Test method lookup. with pytest.raises(plum.NotFoundLookupError)...
plum.AmbiguousLookupError)
pytest.raises
complex_expr
tests/advanced/test_cases.py
test_inheritance_exceptions
146
null
beartype/plum
import collections import math import operator from functools import wraps from typing import Union import pytest import plum def dec(f): @wraps(f) def f_wrapped(*args, **kw_args): return f(*args, **kw_args) return f_wrapped def test_none(dispatch: plum.Dispatcher): @dispatch def f(x: N...
None
assert
none_literal
tests/advanced/test_advanced.py
test_none
327
null
beartype/plum
import pytest import plum from plum._signature import Signature as Sig def test_dispatch_multi(dispatch: plum.Dispatcher): @dispatch def f(x: int): return "int" @dispatch.multi((float,), Sig(str, precedence=1)) def f(x): return "float or str" assert f(1) == "int" assert f(1.0...
1
assert
numeric_literal
tests/test_dispatcher.py
test_dispatch_multi
69
null
beartype/plum
import typing import warnings from numbers import Number from typing import Union import pytest import plum from plum import add_conversion_method, add_promotion_rule, conversion_method from plum._promotion import _promotion_rule def test_default_conversion_methods(): # Conversion to `tuple`. assert plum.co...
(1,)
assert
collection
tests/test_promotion.py
test_default_conversion_methods
69
null
beartype/plum
from __future__ import annotations import math from typing import Union import pytest import plum dispatch = plum.Dispatcher() @pytest.mark.parametrize("one", [Number(1), "1"]) def test_staticmethod(one): two = Number.add_one(one) assert isinstance(two, Number) assert two.value ==
2
assert
numeric_literal
tests/advanced/test_future_annotations.py
test_staticmethod
52
null
beartype/plum
import abc import os import textwrap import typing import pytest import plum from plum._function import Function, _convert, _owner_transfer from plum._method import Method from plum._resolver import ( AmbiguousLookupError, NotFoundLookupError, _change_function_name, _unwrap_invoked_methods, ) from plu...
C
assert
variable
tests/test_function.py
test_owner_transfer
144
null
beartype/plum
import pytest import plum from plum._signature import Signature as Sig def test_dispatch_function(dispatch: plum.Dispatcher): @dispatch def f(x: int): pass @dispatch(precedence=1) def g(x: float): pass assert set(dispatch.functions.keys()) ==
{"f", "g"}
assert
collection
tests/test_dispatcher.py
test_dispatch_function
16
null
beartype/plum
import platform import textwrap from copy import copy import plum from .util import rich_render from plum._method import Method from plum._signature import Signature def test_instantiation_copy(): def f(x) -> float: return x def f2(x) -> float: return x sig = Signature(int) m = Meth...
f
assert
variable
tests/test_method.py
test_instantiation_copy
30
null
beartype/plum
import platform import textwrap from copy import copy import plum from .util import rich_render from plum._method import Method from plum._signature import Signature def test_equality(): m = Method(int, Signature(int), function_name="int", return_type=int) assert m == Method(int, Signature(int), function_name...
Method(int, Signature(float), function_name="int", return_type=int)
assert
func_call
tests/test_method.py
test_equality
90
null
beartype/plum
import inspect import operator from numbers import Number as Num, Real as Re from typing import Any, Union import pytest from beartype.door import TypeHint import plum from plum import Signature as Sig from plum._util import Missing def _impl(x, y, *z): return str(x) def test_compute_distance(): assert Sig...
0
assert
numeric_literal
tests/test_signature.py
test_compute_distance
355
null
beartype/plum
import abc import os import textwrap import typing import pytest import plum from plum._function import Function, _convert, _owner_transfer from plum._method import Method from plum._resolver import ( AmbiguousLookupError, NotFoundLookupError, _change_function_name, _unwrap_invoked_methods, ) from plu...
g
assert
variable
tests/test_function.py
test_function
49
null
beartype/plum
import abc import sys import typing from typing import Literal import pytest from plum._type import ( ModuleType, PromisedType, ResolvableType, _is_hint, is_faithful, resolve_type_hint, type_mapping, ) from plum._util import Callable skip_if_less_than_py310 = pytest.mark.skipif( sys.v...
real
assert
variable
tests/test_type.py
test_resolve_type_hint
185
null
beartype/plum
import pytest import plum dispatch = plum.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): return "two or more numbers" def f(a: Num, b: Num, *cs: Re): return "two numb...
"fallback"
assert
string_literal
tests/advanced/test_cases.py
test_varargs
193
null
beartype/plum
import builtins import inspect import typing import pytest from rich.text import Text from .util import rich_render from plum.repr import _repr_mimebundle_from_rich_, _safe_getfile, repr_type def test_repr_type(): assert rich_render(repr_type(int)).strip() ==
"int"
assert
string_literal
tests/test_repr.py
test_repr_type
17
null
beartype/plum
import builtins import inspect import typing import pytest from rich.text import Text from .util import rich_render from plum.repr import _repr_mimebundle_from_rich_, _safe_getfile, repr_type def test_repr_type(): assert rich_render(repr_type(int)).strip() == "int" assert rich_render(repr_type(A)).strip() ==...
"typing"
assert
string_literal
tests/test_repr.py
test_repr_type
19
null
beartype/plum
import plum 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 plum.Function._instances: f._resolve_pending_registrations() def...
0
assert
numeric_literal
tests/test_cache.py
test_cache_clearing
132
null
beartype/plum
import pytest import plum dispatch = plum.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 zero. return a def mul_preced...
SpecialisedElement
assert
variable
tests/advanced/test_precedence.py
test_precedence
50
null
beartype/plum
import pytest import plum import plum._autoreload as ar 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 never activated", ): plum.deactivate_autoreload() ...
None
assert
none_literal
tests/test_autoreload.py
test_autoreload_activate_deactivate
20
null
beartype/plum
import sys from typing import Union import numpy as np import pytest from plum._util import ( Comparable, Missing, get_class, get_context, is_in_class, wrap_lambda, ) from plum.repr import repr_short def test_repr_short(): class A: pass assert repr_short(int) ==
"int"
assert
string_literal
tests/test_util.py
test_repr_short
22
null
beartype/plum
import platform import textwrap from copy import copy import plum from .util import rich_render from plum._method import Method from plum._signature import Signature def test_instantiation_copy(): def f(x) -> float: return x def f2(x) -> float: return x sig = Signature(int) m = Meth...
sig
assert
variable
tests/test_method.py
test_instantiation_copy
28
null
beartype/plum
import plum 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 plum.Function._instances: f._resolve_pending_registrations() def...
None
assert
none_literal
tests/test_cache.py
test_cache_function
55
null
beartype/plum
from typing import Union import pytest import plum 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"
assert
string_literal
tests/advanced/test_return_type.py
test_inheritance
42
null
beartype/plum
import sys import textwrap import warnings import pytest import plum from plum._method import Method from plum._resolver import ( MethodRedefinitionWarning, Resolver, _document, _render_function_call, ) def test_register(): r = Resolver() def f(*xs): return xs # Test that faithf...
new_m
assert
variable
tests/test_resolver.py
test_register
146
null
beartype/plum
import abc import os import textwrap import typing import pytest import plum from plum._function import Function, _convert, _owner_transfer from plum._method import Method from plum._resolver import ( AmbiguousLookupError, NotFoundLookupError, _change_function_name, _unwrap_invoked_methods, ) from plu...
"f"
assert
string_literal
tests/test_function.py
test_function
45
null
beartype/plum
import inspect import operator from numbers import Number as Num, Real as Re from typing import Any, Union import pytest from beartype.door import TypeHint import plum from plum import Signature as Sig from plum._util import Missing def _impl(x, y, *z): return str(x) def assert_signature(f, *types, varargs=Mis...
Any)
assert_*
variable
tests/test_signature.py
test_signature_from_callable
415
null
beartype/plum
import collections import math import operator from functools import wraps from typing import Union import pytest import plum def dec(f): @wraps(f) def f_wrapped(*args, **kw_args): return f(*args, **kw_args) return f_wrapped def test_equivalent_method_override(dispatch: plum.Dispatcher): @d...
1
assert
numeric_literal
tests/advanced/test_advanced.py
test_equivalent_method_override
362
null
beartype/plum
import typing import warnings from numbers import Number from typing import Union import pytest import plum from plum import add_conversion_method, add_promotion_rule, conversion_method from plum._promotion import _promotion_rule def test_convert_resolve_type_hints(convert): add_conversion_method(int, float, lam...
1
assert
numeric_literal
tests/test_promotion.py
test_convert_resolve_type_hints
64
null
beartype/plum
import plum 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 plum.Function._instances: f._resolve_pending_registrations() def...
2000 * dur
assert
complex_expr
tests/test_cache.py
assert_cache_performance
29
null
beartype/plum
import platform import textwrap from copy import copy import plum from .util import rich_render from plum._method import Method from plum._signature import Signature def test_autodetect_name_return(): def f(x) -> float: return x sig = Signature(int) m = Method(f, sig) assert m.function_name ...
float
assert
variable
tests/test_method.py
test_autodetect_name_return
83
null
beartype/plum
import abc import os import textwrap import typing import pytest import plum from plum._function import Function, _convert, _owner_transfer from plum._method import Method from plum._resolver import ( AmbiguousLookupError, NotFoundLookupError, _change_function_name, _unwrap_invoked_methods, ) from plu...
[]
assert
collection
tests/test_function.py
test_register
330
null
beartype/plum
import pytest import plum from plum._signature import Signature as Sig def test_dispatch_multi(dispatch: plum.Dispatcher): @dispatch def f(x: int): return "int" @dispatch.multi((float,), Sig(str, precedence=1)) def f(x): return "float or str" assert f(1) ==
"int"
assert
string_literal
tests/test_dispatcher.py
test_dispatch_multi
66
null
beartype/plum
import sys from typing import Union import numpy as np import pytest from plum._util import ( Comparable, Missing, get_class, get_context, is_in_class, wrap_lambda, ) from plum.repr import repr_short def test_comparable(): assert Number(1) ==
Number(1)
assert
func_call
tests/test_util.py
test_comparable
53
null
beartype/plum
import collections import math import operator from functools import wraps from typing import Union import pytest import plum @pytest.mark.parametrize( "f, x, res", [ (operator.attrgetter("x"), collections.namedtuple("NamedTuple", "x")(x=1), 1), (operator.itemgetter("x"), {"x": 1}, 1), ...
res
assert
variable
tests/advanced/test_advanced.py
test_strange_functions
207
null
beartype/plum
import pytest import plum import plum._autoreload as ar 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 never activated", ): plum.deactivate_autoreload() ...
"plum._autoreload"
assert
string_literal
tests/test_autoreload.py
test_autoreload_activate_deactivate
22
null
beartype/plum
from __future__ import annotations import math from typing import Union import pytest import plum dispatch = plum.Dispatcher() def test_forward_reference(): one = Number(1) two = Number(2) three = one + two assert isinstance(three, Number) assert three.value ==
3
assert
numeric_literal
tests/advanced/test_future_annotations.py
test_forward_reference
38
null
beartype/plum
import sys from typing import Union import numpy as np import pytest from plum._util import ( Comparable, Missing, get_class, get_context, is_in_class, wrap_lambda, ) from plum.repr import repr_short def test_missing(): # `Missing` cannot be instantiated. with pytest.raises(TypeError)...
sys.modules
assert
complex_expr
tests/test_util.py
test_missing
38
null
beartype/plum
import sys import textwrap import warnings import pytest import plum from plum._method import Method from plum._resolver import ( MethodRedefinitionWarning, Resolver, _document, _render_function_call, ) def test_len(): def f(x): return x r = Resolver() assert len(r) == 0 r.re...
1
assert
numeric_literal
tests/test_resolver.py
test_len
167
null
beartype/plum
import abc from numbers import Number from typing import Union import numpy as np import pytest import plum from plum import Val from plum._parametric import is_concrete, is_type @pytest.mark.parametrize("metaclass", [type, MyType]) def test_parametric(metaclass): class Base1: pass class Base2: ...
"1"
assert
string_literal
tests/test_parametric.py
test_parametric
74
null
beartype/plum
import plum 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 plum.Function._instances: f._resolve_pending_registrations() def...
1
assert
numeric_literal
tests/test_cache.py
test_cache_function
61
null
beartype/plum
import sys from typing import Union import numpy as np import pytest from plum._util import ( Comparable, Missing, get_class, get_context, is_in_class, wrap_lambda, ) from plum.repr import repr_short def f(self): pass def test_get_context(): assert get_context(A.f) ==
"tests.test_util"
assert
string_literal
tests/test_util.py
test_get_context
91
null
beartype/plum
import abc from numbers import Number from typing import Union import numpy as np import pytest import plum from plum import Val from plum._parametric import is_concrete, is_type @pytest.mark.parametrize("metaclass", [type, MyType]) def test_parametric(metaclass): class Base1: pass class Base2: ...
1
assert
numeric_literal
tests/test_parametric.py
test_parametric
73
null
beartype/plum
import sys from typing import Union import numpy as np import pytest from plum._util import ( Comparable, Missing, get_class, get_context, is_in_class, wrap_lambda, ) from plum.repr import repr_short def test_repr_short(): class A: pass assert repr_short(int) == "int" as...
"tests.test_util.test_repr_short.<locals>.A"
assert
string_literal
tests/test_util.py
test_repr_short
23
null
beartype/plum
import sys from typing import Union import numpy as np import pytest from plum._util import ( Comparable, Missing, get_class, get_context, is_in_class, wrap_lambda, ) from plum.repr import repr_short def test_repr_short(): class A: pass assert repr_short(int) == "int" ass...
"int | float"
assert
string_literal
tests/test_util.py
test_repr_short
25
null
beartype/plum
import sys from typing import Union import numpy as np import pytest from plum._util import ( Comparable, Missing, get_class, get_context, is_in_class, wrap_lambda, ) from plum.repr import repr_short def test_repr_short(): class A: pass assert repr_short(int) == "int" ass...
"typing.Union[int, float]"
assert
string_literal
tests/test_util.py
test_repr_short
24
null
beartype/plum
import pytest import plum dispatch = plum.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 zero. return a def mul_preced...
ZeroElement
assert
variable
tests/advanced/test_precedence.py
test_precedence
49
null
beartype/plum
import plum 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 plum.Function._instances: f._resolve_pending_registrations() def...
lambda x: ANative.go_again(a_native, x))
assert_*
func_call
tests/test_cache.py
test_cache_class
117
null
beartype/plum
import plum 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 plum.Function._instances: f._resolve_pending_registrations() def...
50 * dur_native
assert
complex_expr
tests/test_cache.py
assert_cache_performance
26
null
beartype/plum
import abc import os import textwrap import typing import pytest import plum from plum._function import Function, _convert, _owner_transfer from plum._method import Method from plum._resolver import ( AmbiguousLookupError, NotFoundLookupError, _change_function_name, _unwrap_invoked_methods, ) from plu...
A
assert
variable
tests/test_function.py
test_owner
104
null
beartype/plum
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() ...
"int | str | float | complex"
assert
string_literal
tests/test_alias.py
test_uniontype_alias
53
null
beartype/plum
from typing import Union import pytest import plum def test_inheritance(): b = B() assert b.do(1) == 1 assert b.do(b) ==
b
assert
variable
tests/advanced/test_return_type.py
test_inheritance
39
null
beartype/plum
import inspect import operator from numbers import Number as Num, Real as Re from typing import Any, Union import pytest from beartype.door import TypeHint import plum from plum import Signature as Sig from plum._util import Missing def _impl(x, y, *z): return str(x) def assert_signature(f, *types, varargs=Mis...
f)
assert_*
variable
tests/test_signature.py
test_signature_from_callable
408
null
beartype/plum
import collections import math import operator from functools import wraps from typing import Union import pytest import plum def test_invoke(dispatch: plum.Dispatcher): @dispatch() def f(): return "fallback" @dispatch def f(x: int): return "int" @dispatch def f(x: str): ...
"int"
assert
string_literal
tests/advanced/test_advanced.py
test_invoke
136
null
beartype/plum
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() ...
"int | None"
assert
string_literal
tests/test_alias.py
test_optional
59
null
beartype/plum
import abc import sys import typing from typing import Literal import pytest from plum._type import ( ModuleType, PromisedType, ResolvableType, _is_hint, is_faithful, resolve_type_hint, type_mapping, ) from plum._util import Callable skip_if_less_than_py310 = pytest.mark.skipif( sys.v...
0
assert
numeric_literal
tests/test_type.py
test_is_faithful_literal
281
null
beartype/plum
import sys from typing import Union import numpy as np import pytest from plum._util import ( Comparable, Missing, get_class, get_context, is_in_class, wrap_lambda, ) from plum.repr import repr_short def f(self): pass def test_wrap_lambda(): assert wrap_lambda(int)("1") ==
1
assert
numeric_literal
tests/test_util.py
test_wrap_lambda
75
null
beartype/plum
import inspect import operator from numbers import Number as Num, Real as Re from typing import Any, Union import pytest from beartype.door import TypeHint import plum from plum import Signature as Sig from plum._util import Missing def _impl(x, y, *z): return str(x) def test_hash(): assert hash(Sig(int)) ...
3
assert
numeric_literal
tests/test_signature.py
test_hash
94
null
beartype/plum
import abc import sys import typing from typing import Literal import pytest from plum._type import ( ModuleType, PromisedType, ResolvableType, _is_hint, is_faithful, resolve_type_hint, type_mapping, ) from plum._util import Callable skip_if_less_than_py310 = pytest.mark.skipif( sys.v...
type
assert
variable
tests/test_type.py
test_moduletype
60
null
beartype/plum
import abc import sys import typing from typing import Literal import pytest from plum._type import ( ModuleType, PromisedType, ResolvableType, _is_hint, is_faithful, resolve_type_hint, type_mapping, ) from plum._util import Callable skip_if_less_than_py310 = pytest.mark.skipif( sys.v...
module.B
assert
complex_expr
tests/test_type.py
test_moduletype_faithful
114
null
beartype/plum
import pytest import plum dispatch = plum.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): return "two or more numbers" def f(a: Num, b: Num, *cs: Re): return "two numb...
LookupError)
pytest.raises
variable
tests/advanced/test_cases.py
test_varargs
199
null
beartype/plum
import sys import textwrap import warnings import pytest import plum from plum._method import Method from plum._resolver import ( MethodRedefinitionWarning, Resolver, _document, _render_function_call, ) def test_render_function_call(): assert _render_function_call("f", (1,)) == "f(1)" assert ...
"f(int, int)"
assert
string_literal
tests/test_resolver.py
test_render_function_call
21
null
beartype/plum
from __future__ import annotations import math from typing import Union import pytest import plum dispatch = plum.Dispatcher() def test_extension(dispatch: plum.Dispatcher): @dispatch def f(x: int): return "int" assert f(1) ==
"int"
assert
string_literal
tests/advanced/test_future_annotations.py
test_extension
66
null
beartype/plum
import plum 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 plum.Function._instances: f._resolve_pending_registrations() def...
lambda x: a_native.go(x))
assert_*
func_call
tests/test_cache.py
test_cache_class
114
null
beartype/plum
import builtins import inspect import typing import pytest from rich.text import Text from .util import rich_render from plum.repr import _repr_mimebundle_from_rich_, _safe_getfile, repr_type def test_repr_mimebundle_from_rich(): class A: def __rich_console__(self, console, options): yield Te...
v
assert
variable
tests/test_repr.py
test_repr_mimebundle_from_rich
28
null
beartype/plum
import abc from numbers import Number from typing import Union import numpy as np import pytest import plum from plum import Val from plum._parametric import is_concrete, is_type @pytest.mark.parametrize("metaclass", [type, MyType]) def test_parametric(metaclass): class Base1: pass class Base2: ...
A
assert
variable
tests/test_parametric.py
test_parametric
55
null
beartype/plum
from __future__ import annotations import math from typing import Union import pytest import plum dispatch = plum.Dispatcher() def test_extension_c(dispatch: plum.Dispatcher): @dispatch def f(x: int): return x assert f(1) ==
1
assert
numeric_literal
tests/advanced/test_future_annotations.py
test_extension_c
91
null
beartype/plum
import sys import textwrap import warnings import pytest import plum from plum._method import Method from plum._resolver import ( MethodRedefinitionWarning, Resolver, _document, _render_function_call, ) def test_len(): def f(x): return x r = Resolver() assert len(r) == 0 r.re...
2
assert
numeric_literal
tests/test_resolver.py
test_len
169
null
beartype/plum
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() ...
"typing.Union[IntStrFloat]"
assert
string_literal
tests/test_alias.py
test_union_alias
39
null
beartype/plum
import abc import sys import typing from typing import Literal import pytest from plum._type import ( ModuleType, PromisedType, ResolvableType, _is_hint, is_faithful, resolve_type_hint, type_mapping, ) from plum._util import Callable skip_if_less_than_py310 = pytest.mark.skipif( sys.v...
int
assert
variable
tests/test_type.py
test_resolvabletype
30
null
beartype/plum
import abc import sys import typing from typing import Literal import pytest from plum._type import ( ModuleType, PromisedType, ResolvableType, _is_hint, is_faithful, resolve_type_hint, type_mapping, ) from plum._util import Callable skip_if_less_than_py310 = pytest.mark.skipif( sys.v...
module.C
assert
complex_expr
tests/test_type.py
test_moduletype_faithful
121
null
beartype/plum
import platform import textwrap from copy import copy import plum from .util import rich_render from plum._method import Method from plum._signature import Signature def test_instantiation_copy(): def f(x) -> float: return x def f2(x) -> float: return x sig = Signature(int) m = Meth...
complex
assert
variable
tests/test_method.py
test_instantiation_copy
29
null
beartype/plum
import pytest import plum from plum._signature import Signature as Sig def test_bound_function_attributes(dispatch: plum.Dispatcher): """Test the attributes on a bound function.""" class A: @dispatch def f(self, x: int): pass a = A() # The 'methods' should point to those...
hash(a.f._f.dispatch)
assert
func_call
tests/test_dispatcher.py
test_bound_function_attributes
54
null
beartype/plum
import sys from typing import Union import numpy as np import pytest from plum._util import ( Comparable, Missing, get_class, get_context, is_in_class, wrap_lambda, ) from plum.repr import repr_short def f(self): pass def test_get_class(): assert get_class(A.f) ==
"tests.test_util.A"
assert
string_literal
tests/test_util.py
test_get_class
86
null
beartype/plum
import typing import warnings from numbers import Number from typing import Union import pytest import plum from plum import add_conversion_method, add_promotion_rule, conversion_method from plum._promotion import _promotion_rule def test_convert(convert): # Test basic conversion. assert convert(1.0, float) ...
r
assert
variable
tests/test_promotion.py
test_convert
34
null
beartype/plum
import collections import math import operator from functools import wraps from typing import Union import pytest import plum def test_defaults(dispatch: plum.Dispatcher): y_default = 3 @dispatch def f(x: int, y: int = y_default, *, option=None): return y @dispatch def f(x: float, y: in...
4
assert
numeric_literal
tests/advanced/test_advanced.py
test_defaults
36
null
shotgun-sh/shotgun
from shotgun.tui.screens.chat_screen.hint_message import HintMessage, HintMessageWidget def test_hint_message_widget_initialization(): """Test HintMessageWidget can be initialized.""" hint = HintMessage(message="Test message") widget = HintMessageWidget(hint) assert widget.message ==
hint
assert
variable
test/unit/tui/screens/chat_screen/test_hint_message.py
test_hint_message_widget_initialization
83
null
shotgun-sh/shotgun
from pathlib import Path import pytest from pydantic_ai import RunUsage from shotgun.agents.config.models import ProviderType from shotgun.agents.usage_manager import ( SessionUsageManager, UsageSummaryEntry, format_usage_hint, ) def usage_home(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path: ...
hint
assert
variable
test/unit/agents/test_usage_manager.py
test_format_usage_hint_handles_empty_breakdown
86
null
shotgun-sh/shotgun
from datetime import datetime, timezone from shotgun.cli.spec.models import SpecMeta def test_spec_meta_creation() -> None: """Test SpecMeta model creation.""" now = datetime.now(timezone.utc) meta = SpecMeta( version_id="version-123", spec_id="spec-456", spec_name="My Test Spec", ...
now
assert
variable
test/unit/cli/spec/test_models.py
test_spec_meta_creation
25
null
shotgun-sh/shotgun
import pytest from pydantic_ai import RunContext from shotgun.agents.models import AgentDeps from shotgun.agents.tools.codebase import directory_lister from shotgun.codebase.models import CodebaseGraph @pytest.mark.integration @pytest.mark.asyncio async def test_directory_lister_root_directory( indexed_graph: Cod...
"."
assert
string_literal
test/integration/codebase/tools/test_directory_lister.py
test_directory_lister_root_directory
24
null