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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_dunders.py | test_default | assert | complex_expr | 70 | import copy
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_is_slot_cls,
_make_init,
fields,
make_class,
)
from attr.validators import instance_of
from .utils import si... | i.a | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_dunders.py | test_default | assert | complex_expr | 71 | import copy
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_is_slot_cls,
_make_init,
fields,
make_class,
)
from attr.validators import instance_of
from .utils import si... | i.b | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_dunders.py | test_default | assert | complex_expr | 72 | import copy
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_is_slot_cls,
_make_init,
fields,
make_class,
)
from attr.validators import instance_of
from .utils import si... | i.c | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_dunders.py | test_hash_mirrors_eq | assert | func_call | 69 | import copy
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_is_slot_cls,
_make_init,
fields,
make_class,
)
from attr.validators import instance_of
from .utils import si... | C(1) | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_dunders.py | test_hash_attribute_mirrors_eq | assert | func_call | 64 | import copy
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_is_slot_cls,
_make_init,
fields,
make_class,
)
from attr.validators import instance_of
from .utils import si... | C(2) | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_dunders.py | test_sets_attributes | assert | complex_expr | 61 | import copy
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_is_slot_cls,
_make_init,
fields,
make_class,
)
from attr.validators import instance_of
from .utils import si... | obj.a | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_dunders.py | test_sets_attributes | assert | complex_expr | 62 | import copy
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_is_slot_cls,
_make_init,
fields,
make_class,
)
from attr.validators import instance_of
from .utils import si... | obj.b | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_dunders.py | test_eq_ignore_attrib | assert | func_call | 65 | import copy
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_is_slot_cls,
_make_init,
fields,
make_class,
)
from attr.validators import instance_of
from .utils import si... | C(2, 2) | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_dunders.py | test_underscores | assert | func_call | 68 | import copy
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_is_slot_cls,
_make_init,
fields,
make_class,
)
from attr.validators import instance_of
from .utils import si... | repr(i) | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_dunders.py | test_str | assert | variable | 71 | import copy
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_is_slot_cls,
_make_init,
fields,
make_class,
)
from attr.validators import instance_of
from .utils import si... | add_str | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_dunders.py | test_hash_mirrors_eq | assert | func_call | 66 | import copy
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_is_slot_cls,
_make_init,
fields,
make_class,
)
from attr.validators import instance_of
from .utils import si... | hash(i) | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_dunders.py | test_hash_works | assert | func_call | 72 | import copy
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_is_slot_cls,
_make_init,
fields,
make_class,
)
from attr.validators import instance_of
from .utils import si... | hash(b) | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_filters.py | test_allow | assert | bool_literal | 29 | import pytest
import attr
from attr import fields
from attr.filters import _split_what, exclude, include
class TestInclude:
@pytest.mark.parametrize(
"incl,value",
[
((int,), 42),
((str,), "hello"),
((str, fields(C).a), 42),
((str, fields(C).b), "h... | True | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_filters.py | test_drop_class | assert | bool_literal | 29 | import pytest
import attr
from attr import fields
from attr.filters import _split_what, exclude, include
class TestInclude:
@pytest.mark.parametrize(
"incl,value",
[
((str,), 42),
((int,), "hello"),
((str, fields(C).b), 42),
((int, fields(C).b), "h... | False | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_filters.py | test_splits | assert | func_call | 15 | import pytest
import attr
from attr import fields
from attr.filters import _split_what, exclude, include
class TestSplitWhat:
def test_splits(self):
"""
Splits correctly.
"""
asser | _split_what((str, "123", fields(C).a, int, "abcd")) | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_funcs.py | test_sets_no_retain | assert | variable | 48 | from collections import OrderedDict
from typing import Generic, TypeVar
import pytest
from hypothesis import assume, given
from hypothesis import strategies as st
import attr
from attr import asdict, assoc, astuple, evolve, fields, has
from attr._compat import Mapping, Sequence
from attr.exceptions import AttrsAttr... | d | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_funcs.py | test_private | assert | numeric_literal | 46 | from collections import OrderedDict
from typing import Generic, TypeVar
import pytest
from hypothesis import assume, given
from hypothesis import strategies as st
import attr
from attr import asdict, assoc, astuple, evolve, fields, has
from attr._compat import Mapping, Sequence
from attr.exceptions import AttrsAttr... | 2 | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_funcs.py | test_change | assert | variable | 52 | from collections import OrderedDict
from typing import Generic, TypeVar
import pytest
from hypothesis import assume, given
from hypothesis import strategies as st
import attr
from attr import asdict, assoc, astuple, evolve, fields, has
from attr._compat import Mapping, Sequence
from attr.exceptions import AttrsAttr... | v | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_funcs.py | test_empty | assert | variable | 50 | from collections import OrderedDict
from typing import Generic, TypeVar
import pytest
from hypothesis import assume, given
from hypothesis import strategies as st
import attr
from attr import asdict, assoc, astuple, evolve, fields, has
from attr._compat import Mapping, Sequence
from attr.exceptions import AttrsAttr... | i2 | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_funcs.py | test_dicts | assert | variable | 44 | from collections import OrderedDict
from typing import Generic, TypeVar
import pytest
from hypothesis import assume, given
from hypothesis import strategies as st
import attr
from attr import asdict, assoc, astuple, evolve, fields, has
from attr._compat import Mapping, Sequence
from attr.exceptions import AttrsAttr... | res | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_funcs.py | test_recurse_property | assert_* | variable | 68 | from collections import OrderedDict
from typing import Generic, TypeVar
import pytest
from hypothesis import assume, given
from hypothesis import strategies as st
import attr
from attr import asdict, assoc, astuple, evolve, fields, has
from attr._compat import Mapping, Sequence
from attr.exceptions import AttrsAttr... | obj_dict) | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_funcs.py | test_unknown | pytest.raises | variable | 44 | from collections import OrderedDict
from typing import Generic, TypeVar
import pytest
from hypothesis import assume, given
from hypothesis import strategies as st
import attr
from attr import asdict, assoc, astuple, evolve, fields, has
from attr._compat import Mapping, Sequence
from attr.exceptions import AttrsAttr... | TypeError) | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_funcs.py | test_recurse_property | assert_* | variable | 53 | from collections import OrderedDict
from typing import Generic, TypeVar
import pytest
from hypothesis import assume, given
from hypothesis import strategies as st
import attr
from attr import asdict, assoc, astuple, evolve, fields, has
from attr._compat import Mapping, Sequence
from attr.exceptions import AttrsAttr... | obj_tuple) | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_functional.py | test_subclassing_with_extra_attrs | assert | numeric_literal | 28 | import inspect
import pickle
from copy import deepcopy
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import NOTHING, Attribute
from attr.exceptions import FrozenInstanceError
class TestFunctional:
@pytest.mark.parametrize("cls", [Sub, SubSlo... | 2 | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_functional.py | test_dict_patch_class | assert | variable | 29 | import inspect
import pickle
from copy import deepcopy
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import NOTHING, Attribute
from attr.exceptions import FrozenInstanceError
class TestFunctional:
def test_dict_patch_class(self):
"""... | C | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_functional.py | test_auto_exc | assert | variable | 59 | import inspect
import pickle
from copy import deepcopy
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import NOTHING, Attribute
from attr.exceptions import FrozenInstanceError
class TestFunctional:
def test_auto_exc(self, slots, frozen):
... | e1 | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_functional.py | test_auto_exc | assert | variable | 61 | import inspect
import pickle
from copy import deepcopy
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import NOTHING, Attribute
from attr.exceptions import FrozenInstanceError
class TestFunctional:
def test_auto_exc(self, slots, frozen):
... | e2 | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_functional.py | test_default_decorator | assert | func_call | 34 | import inspect
import pickle
from copy import deepcopy
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import NOTHING, Attribute
from attr.exceptions import FrozenInstanceError
class TestFunctional:
def test_default_decorator(self):
""... | C() | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_functional.py | test_no_setattr_if_validate_without_validators | assert | variable | 38 | import inspect
import pickle
from copy import deepcopy
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import NOTHING, Attribute
from attr.exceptions import FrozenInstanceError
class TestFunctional:
def test_no_setattr_if_validate_without_vali... | src | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_hooks.py | test_hook_with_inheritance | assert | collection | 27 | from datetime import datetime
from typing import Dict, List
import attr
class TestTransformHook:
def test_hook_with_inheritance(self):
"""
The hook receives all fields from base classes.
"""
def hook(cls, attribs):
assert [a.name for a in attribs] == ["x", "y"]
... | {"y": 2} | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_hooks.py | test_hook_remove_field | assert | collection | 23 | from datetime import datetime
from typing import Dict, List
import attr
class TestTransformHook:
def test_hook_remove_field(self):
"""
It is possible to remove fields via the hook.
"""
def hook(cls, attribs):
attr.resolve_types(cls, attribs=attribs)
return... | {"y": 2.7} | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_hooks.py | hook | assert | collection | 10 | from datetime import datetime
from typing import Dict, List
import attr
class TestTransformHook:
def hook(cls, attribs):
assert [a.name for a in attribs] == | ["x", "y"] | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_hooks.py | test_attrs_attrclass | assert | string_literal | 22 | from datetime import datetime
from typing import Dict, List
import attr
class TestTransformHook:
def test_attrs_attrclass(self):
"""
The list of attrs returned by a field_transformer is converted to
"AttrsClass" again.
Regression test for #821.
"""
@attr.s(auto_a... | "CAttributes" | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_hooks.py | test_hook_applied_modify_attrib | assert | func_call | 24 | from datetime import datetime
from typing import Dict, List
import attr
class TestTransformHook:
def test_hook_applied_modify_attrib(self):
"""
The transform hook can modify attributes.
"""
def hook(cls, attribs):
attr.resolve_types(cls, attribs=attribs)
r... | C(x=3, y=3.14) | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_hooks.py | test_hook_add_field | assert | collection | 23 | from datetime import datetime
from typing import Dict, List
import attr
class TestTransformHook:
def test_hook_add_field(self):
"""
It is possible to add fields via the hook.
"""
def hook(cls, attribs):
a1 = attribs[0]
a2 = a1.evolve(name="new")
... | {"x": 1, "new": 2} | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_hooks.py | test_hook_applied_auto_attrib | assert | collection | 26 | from datetime import datetime
from typing import Dict, List
import attr
class TestTransformHook:
def test_hook_applied_auto_attrib(self):
"""
The transform hook is applied to all attributes and type annotations
are detected.
"""
results = []
def hook(cls, attribs)... | [("x", int), ("y", str)] | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_hooks.py | test_hook_applied | assert | collection | 27 | from datetime import datetime
from typing import Dict, List
import attr
class TestTransformHook:
def test_hook_applied(self):
"""
The transform hook is applied to all attributes. Types can be missing,
explicitly set, or annotated.
"""
results = []
def hook(cls, a... | [("x", None), ("y", int), ("z", float)] | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_hooks.py | test_hook_override_alias | assert | func_call | 23 | from datetime import datetime
from typing import Dict, List
import attr
class TestTransformHook:
def test_hook_override_alias(self):
"""
It is possible to set field alias via hook
"""
def use_dataclass_names(cls, attribs):
return [a.evolve(alias=a.name) for a in attri... | NameCase( 1, 2, 3 ) | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_hooks.py | test_asdict_calls | assert | collection | 32 | from datetime import datetime
from typing import Dict, List
import attr
class TestAsDictHook:
def test_asdict_calls(self):
"""
The correct instances and attribute names are passed to the hook.
"""
calls = []
def hook(inst, a, v):
calls.append((inst, a.name if ... | [ (inst, "a", inst.a), (inst.a, "x", inst.a.x), (inst, "b", inst.b), (inst.b[0], "x", inst.b[0].x), (inst, "c", inst.c), (None, None, "spam"), (inst.c["spam"], "x", inst.c["spam"].x), ] | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_hooks.py | test_asdict | assert | collection | 39 | from datetime import datetime
from typing import Dict, List
import attr
class TestAsDictHook:
def test_asdict(self):
"""
asdict() calls the hooks in attrs classes and in other datastructures
like lists or dicts.
"""
def hook(inst, a, v):
if isinstance(v, dateti... | { "a": {"x": 1, "y": ["2020-07-01T00:00:00"]}, "b": [{"x": 2, "y": ["2020-07-02T00:00:00"]}], "c": {"spam": {"x": 3, "y": ["2020-07-03T00:00:00"]}}, "d": {"eggs": "2020-07-04T00:00:00"}, } | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_init_subclass.py | test_init_subclass_attrs | assert | func_call | 19 | import attr
def test_init_subclass_attrs():
"""
`__init_subclass__` works with attrs classes as long as slots=False.
"""
@attr.s(slots=False)
class Base:
def __init_subclass__(cls, param, **kw):
super().__init_subclass__(**kw)
cls.param = param
@attr.s
clas... | Attrs().param | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_init_subclass.py | test_init_subclass_vanilla | assert | func_call | 19 | import attr
def test_init_subclass_vanilla(slots):
"""
`super().__init_subclass__` can be used if the subclass is not an attrs
class both with dict and slotted classes.
"""
@attr.s(slots=slots)
class Base:
def __init_subclass__(cls, param, **kw):
super().__init_subclass__(*... | Vanilla().param | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_make.py | test_kw_only | assert | numeric_literal | 88 | import copy
import functools
import gc
import inspect
import itertools
import sys
from operator import attrgetter
from typing import Generic, TypeVar
import pytest
from hypothesis import assume, given
from hypothesis.strategies import booleans, integers, lists, sampled_from, text
import attr
from attr import _conf... | 3 | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_make.py | test_kw_only | assert | numeric_literal | 89 | import copy
import functools
import gc
import inspect
import itertools
import sys
from operator import attrgetter
from typing import Generic, TypeVar
import pytest
from hypothesis import assume, given
from hypothesis.strategies import booleans, integers, lists, sampled_from, text
import attr
from attr import _conf... | 1 | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_make.py | test_adds_keyword_only_arguments | assert | numeric_literal | 79 | import copy
import functools
import gc
import inspect
import itertools
import sys
from operator import attrgetter
from typing import Generic, TypeVar
import pytest
from hypothesis import assume, given
from hypothesis.strategies import booleans, integers, lists, sampled_from, text
import attr
from attr import _conf... | 2 | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_make.py | test_adds_keyword_only_arguments | assert | numeric_literal | 81 | import copy
import functools
import gc
import inspect
import itertools
import sys
from operator import attrgetter
from typing import Generic, TypeVar
import pytest
from hypothesis import assume, given
from hypothesis.strategies import booleans, integers, lists, sampled_from, text
import attr
from attr import _conf... | 4 | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_make.py | test_ignores_kw_only_when_init_is_false | assert | numeric_literal | 76 | import copy
import functools
import gc
import inspect
import itertools
import sys
from operator import attrgetter
from typing import Generic, TypeVar
import pytest
from hypothesis import assume, given
from hypothesis.strategies import booleans, integers, lists, sampled_from, text
import attr
from attr import _conf... | 0 | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_next_gen.py | test_auto_attribs_partially_annotated | assert | numeric_literal | 30 | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
class TestNextGen:
def test_auto_attribs_partially_annotated(self):
"""
define infers auto_attribs=True if any type annotations are found
... | 10 | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_next_gen.py | test_exception | pytest.raises | variable | 24 | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
class TestNextGen:
def test_exception(self):
"""
Exceptions are detected and correctly handled.
"""
@attrs.define
cl... | E) | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_next_gen.py | test_discard_context | assert | none_literal | 41 | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
class TestNextGen:
@pytest.mark.parametrize(
"decorator",
[
partial(_attr.s, frozen=True, slots=True, auto_exc=True),
... | None | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_next_gen.py | test_exception | assert | complex_expr | 30 | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
class TestNextGen:
def test_exception(self):
"""
Exceptions are detected and correctly handled.
"""
@attrs.define
cl... | e.msg | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_next_gen.py | test_exception | assert | complex_expr | 29 | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
class TestNextGen:
def test_exception(self):
"""
Exceptions are detected and correctly handled.
"""
@attrs.define
cl... | e.args | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_next_gen.py | test_converts_and_validates_by_default | assert | complex_expr | 33 | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
class TestNextGen:
def test_converts_and_validates_by_default(self):
"""
If no on_setattr is set, assume setters.convert, setters.validate.
... | inst.x | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_next_gen.py | test_mro_ng | assert | func_call | 45 | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
class TestNextGen:
def test_mro_ng(self):
"""
Attributes and methods are looked up the same way in NG by default.
See #428
"... | d.xx() | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_next_gen.py | test_exception | assert | complex_expr | 31 | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
class TestNextGen:
def test_exception(self):
"""
Exceptions are detected and correctly handled.
"""
@attrs.define
cl... | e.other | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_next_gen.py | test_subclass_frozen | assert | func_call | 32 | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
class TestNextGen:
def test_subclass_frozen(self):
"""
It's possible to subclass an `attrs.frozen` class and the frozen-ness
is inher... | B(1, 2) | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_next_gen.py | test_no_order | assert | func_call | 25 | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
class TestNextGen:
def test_no_order(self):
"""
Order is off by default but can be added.
"""
with pytest.raises(TypeError):
... | Ordered(2) | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_next_gen.py | test_no_order | pytest.raises | variable | 18 | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
class TestNextGen:
def test_no_order(self):
"""
Order is off by default but can be added.
"""
with pytest.raises( | TypeError) | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_next_gen.py | test_override_auto_attribs_false | assert | func_call | 26 | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
class TestNextGen:
def test_override_auto_attribs_false(self):
"""
Don't guess if auto_attrib is set explicitly.
Annotated fields th... | NoFields() | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_next_gen.py | test_auto_attribs_detect_fields_and_annotations | assert | collection | 32 | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
class TestNextGen:
def test_auto_attribs_detect_fields_and_annotations(self):
"""
define infers auto_attribs=True if fields have type annotat... | ["x", "y"] | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_next_gen.py | test_subclass_frozen | assert | func_call | 33 | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
class TestNextGen:
def test_subclass_frozen(self):
"""
It's possible to subclass an `attrs.frozen` class and the frozen-ness
is inher... | C(1, 2, 3) | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_next_gen.py | test_discard_context | assert | complex_expr | 40 | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
class TestNextGen:
@pytest.mark.parametrize(
"decorator",
[
partial(_attr.s, frozen=True, slots=True, auto_exc=True),
... | ei.value.x | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_next_gen.py | test_auto_attribs_detect_fields_and_annotations | pytest.raises | variable | 30 | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
class TestNextGen:
def test_auto_attribs_detect_fields_and_annotations(self):
"""
define infers auto_attribs=True if fields have type annotat... | ValueError) | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_packaging.py | test_version | assert | complex_expr | 20 | import sys
import pytest
import attr
import attrs
def _mod(request):
yield request.param
class TestLegacyMetadataHack:
def test_version(self, mod, recwarn):
"""
__version__ returns the correct version and doesn't warn.
"""
assert metadata.version("attrs") == mod.__version__
... | recwarn.list | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_packaging.py | test_title | assert | complex_expr | 18 | import sys
import pytest
import attr
import attrs
def _mod(request):
yield request.param
class TestLegacyMetadataHack:
def test_title(self, mod):
"""
__title__ returns attrs.
"""
with pytest.deprecated_call() as ws:
assert "attrs" == | mod.__title__ | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_packaging.py | test_email | assert | complex_expr | 19 | import sys
import pytest
import attr
import attrs
def _mod(request):
yield request.param
class TestLegacyMetadataHack:
def test_email(self, mod):
"""
__email__ returns Hynek's email address.
"""
with pytest.deprecated_call() as ws:
assert "hs@ox.cx" == | mod.__email__ | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_packaging.py | test_author | assert | complex_expr | 19 | import sys
import pytest
import attr
import attrs
def _mod(request):
yield request.param
class TestLegacyMetadataHack:
def test_author(self, mod):
"""
__author__ returns Hynek.
"""
with pytest.deprecated_call() as ws:
assert "Hynek Schlawack" == | mod.__author__ | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_packaging.py | test_version | assert | complex_expr | 18 | import sys
import pytest
import attr
import attrs
def _mod(request):
yield request.param
class TestLegacyMetadataHack:
def test_version(self, mod, recwarn):
"""
__version__ returns the correct version and doesn't warn.
"""
assert metadata.version("attrs") == | mod.__version__ | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_packaging.py | test_license | assert | complex_expr | 19 | import sys
import pytest
import attr
import attrs
def _mod(request):
yield request.param
class TestLegacyMetadataHack:
def test_license(self, mod):
"""
__license__ returns MIT.
"""
with pytest.deprecated_call() as ws:
assert "MIT" == | mod.__license__ | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_packaging.py | test_copyright | assert | complex_expr | 19 | import sys
import pytest
import attr
import attrs
def _mod(request):
yield request.param
class TestLegacyMetadataHack:
def test_copyright(self, mod):
"""
__copyright__ returns the correct blurp.
"""
with pytest.deprecated_call() as ws:
assert "Copyright (c) 2015... | mod.__copyright__ | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_packaging.py | test_uri | assert | func_call | 20 | import sys
import pytest
import attr
import attrs
def _mod(request):
yield request.param
class TestLegacyMetadataHack:
@pytest.mark.parametrize("name", ["__uri__", "__url__"])
def test_uri(self, mod, name):
"""
__uri__ & __url__ returns the correct project URL.
"""
with ... | getattr(mod, name) | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_packaging.py | test_description | assert | complex_expr | 19 | import sys
import pytest
import attr
import attrs
def _mod(request):
yield request.param
class TestLegacyMetadataHack:
def test_description(self, mod):
"""
__description__ returns the correct description.
"""
with pytest.deprecated_call() as ws:
assert "Classes ... | mod.__description__ | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_packaging.py | test_title | assert | complex_expr | 20 | import sys
import pytest
import attr
import attrs
def _mod(request):
yield request.param
class TestLegacyMetadataHack:
def test_title(self, mod):
"""
__title__ returns attrs.
"""
with pytest.deprecated_call() as ws:
assert "attrs" == mod.__title__
assert... | ws.list[0].message.args[0] | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_packaging.py | test_does_not_exist | pytest.raises | complex_expr | 18 | import sys
import pytest
import attr
import attrs
def _mod(request):
yield request.param
class TestLegacyMetadataHack:
def test_does_not_exist(self, mod):
"""
Asking for unsupported dunders raises an AttributeError.
"""
with | AttributeError, match=f"module {mod.__name__} has no attribute __yolo__") | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_pattern_matching.py | test_simple_match_case | assert | variable | 28 | import pytest
import attr
class TestPatternMatching:
@pytest.mark.parametrize("dec", [attr.s, attr.define, attr.frozen])
def test_simple_match_case(self, dec):
"""
Simple match case statement works as expected with all class
decorators.
"""
@dec
class C:
... | a | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_pattern_matching.py | test_match_args_kw_only | assert | collection | 53 | import pytest
import attr
class TestPatternMatching:
def test_match_args_kw_only(self):
"""
kw_only classes don't generate __match_args__.
kw_only fields are not included in __match_args__.
"""
@attr.define
class C:
a = attr.field(kw_only=True)
... | (a, b) | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_pattern_matching.py | test_simple_match_case | assert | complex_expr | 19 | import pytest
import attr
class TestPatternMatching:
@pytest.mark.parametrize("dec", [attr.s, attr.define, attr.frozen])
def test_simple_match_case(self, dec):
"""
Simple match case statement works as expected with all class
decorators.
"""
@dec
class C:
... | C.__match_args__ | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_pattern_matching.py | test_match_args_kw_only | pytest.raises | complex_expr | 23 | import pytest
import attr
class TestPatternMatching:
def test_match_args_kw_only(self):
"""
kw_only classes don't generate __match_args__.
kw_only fields are not included in __match_args__.
"""
@attr.define
class C:
a = attr.field(kw_only=True)
... | TypeError, match=msg) | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_pyright.py | test_pyright_baseline | assert | variable | 79 | from __future__ import annotations
import json
import shutil
import subprocess
from pathlib import Path
import pytest
import attrs
pytestmark = [
pytest.mark.skipif(
shutil.which("pyright") is None, reason="Requires pyright."
),
]
def parse_pyright_output(test_file: Path) -> set[PyrightDiagnostic]... | diagnostics | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_pyright.py | test_pyright_attrsinstance_compat | assert | variable | 57 | from __future__ import annotations
import json
import shutil
import subprocess
from pathlib import Path
import pytest
import attrs
pytestmark = [
pytest.mark.skipif(
shutil.which("pyright") is None, reason="Requires pyright."
),
]
def parse_pyright_output(test_file: Path) -> set[PyrightDiagnostic]... | expected_diagnostics | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_setattr.py | test_change | assert | complex_expr | 29 | import pickle
import pytest
import attr
from attr import setters
from attr.exceptions import FrozenAttributeError
from attr.validators import instance_of, matches_re
class TestSetAttr:
def test_change(self):
"""
The return value of a hook overwrites the value. But they are not run
on __i... | h.x | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_setattr.py | test_change | assert | complex_expr | 30 | import pickle
import pytest
import attr
from attr import setters
from attr.exceptions import FrozenAttributeError
from attr.validators import instance_of, matches_re
class TestSetAttr:
def test_change(self):
"""
The return value of a hook overwrites the value. But they are not run
on __i... | h.y | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_setattr.py | test_no_validator_no_converter | assert | complex_expr | 27 | import pickle
import pytest
import attr
from attr import setters
from attr.exceptions import FrozenAttributeError
from attr.validators import instance_of, matches_re
class TestSetAttr:
def test_no_validator_no_converter(self):
"""
validate and convert tolerate missing validators and converters.... | c.x | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_setattr.py | test_setattr_auto_detect_if_no_custom_setattr | assert | complex_expr | 31 | import pickle
import pytest
import attr
from attr import setters
from attr.exceptions import FrozenAttributeError
from attr.validators import instance_of, matches_re
class TestSetAttr:
def test_setattr_auto_detect_if_no_custom_setattr(self, slots):
"""
It's possible to remove the on_setattr hoo... | i.x | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_setattr.py | test_frozen_attribute | assert | complex_expr | 28 | import pickle
import pytest
import attr
from attr import setters
from attr.exceptions import FrozenAttributeError
from attr.validators import instance_of, matches_re
class TestSetAttr:
def test_frozen_attribute(self):
"""
Frozen attributes raise FrozenAttributeError, others are not affected.
... | pf.y | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_setattr.py | test_frozen_attribute | assert | complex_expr | 33 | import pickle
import pytest
import attr
from attr import setters
from attr.exceptions import FrozenAttributeError
from attr.validators import instance_of, matches_re
class TestSetAttr:
def test_frozen_attribute(self):
"""
Frozen attributes raise FrozenAttributeError, others are not affected.
... | pf.x | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_setattr.py | test_validator | assert | complex_expr | 33 | import pickle
import pytest
import attr
from attr import setters
from attr.exceptions import FrozenAttributeError
from attr.validators import instance_of, matches_re
class TestSetAttr:
@pytest.mark.parametrize(
"on_setattr",
[setters.validate, [setters.validate], setters.pipe(setters.validate)]... | va.y | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_setattr.py | test_pipe | assert | complex_expr | 30 | import pickle
import pytest
import attr
from attr import setters
from attr.exceptions import FrozenAttributeError
from attr.validators import instance_of, matches_re
class TestSetAttr:
def test_pipe(self):
"""
Multiple hooks are possible, in that case the last return value is
used. They... | p.x1 | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_setattr.py | test_pipe | assert | complex_expr | 31 | import pickle
import pytest
import attr
from attr import setters
from attr.exceptions import FrozenAttributeError
from attr.validators import instance_of, matches_re
class TestSetAttr:
def test_pipe(self):
"""
Multiple hooks are possible, in that case the last return value is
used. They... | p.x2 | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_setattr.py | test_setattr_inherited_do_not_reset_intermediate | assert | bool_literal | 43 | import pickle
import pytest
import attr
from attr import setters
from attr.exceptions import FrozenAttributeError
from attr.validators import instance_of, matches_re
class TestSetAttr:
@pytest.mark.parametrize("a_slots", [True, False])
@pytest.mark.parametrize("b_slots", [True, False])
@pytest.mark.par... | True | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_setattr.py | test_setattr_inherited_do_not_reset_intermediate | assert | bool_literal | 44 | import pickle
import pytest
import attr
from attr import setters
from attr.exceptions import FrozenAttributeError
from attr.validators import instance_of, matches_re
class TestSetAttr:
@pytest.mark.parametrize("a_slots", [True, False])
@pytest.mark.parametrize("b_slots", [True, False])
@pytest.mark.par... | False | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_setattr.py | test_validator | pytest.raises | variable | 30 | import pickle
import pytest
import attr
from attr import setters
from attr.exceptions import FrozenAttributeError
from attr.validators import instance_of, matches_re
class TestSetAttr:
@pytest.mark.parametrize(
"on_setattr",
[setters.validate, [setters.validate], setters.pipe(setters.validate)]... | TypeError) | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_slots.py | test_basic_attr_funcs | assert | variable | 24 | import pickle
import sys
import types
import weakref
from unittest import mock
import pytest
import attr
from attr._compat import PYPY, just_warn, make_set_closure_cell
def test_basic_attr_funcs():
"""
Comparison, `__eq__`, `__hash__`, `__repr__`, `attrs.asdict` work.
"""
a = C1Slots(x=1, y=2)
... | a | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_slots.py | test_slots_unpickle_after_attr_removed | assert | numeric_literal | 69 | import pickle
import sys
import types
import weakref
from unittest import mock
import pytest
import attr
from attr._compat import PYPY, just_warn, make_set_closure_cell
def tests_weakref_does_not_add_when_inheriting_with_weakref():
"""
`weakref_slot=True` does not add a new __weakref__ slot when inheriting... | 1 | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_slots.py | test_slots_unpickle_after_attr_removed | assert | numeric_literal | 70 | import pickle
import sys
import types
import weakref
from unittest import mock
import pytest
import attr
from attr._compat import PYPY, just_warn, make_set_closure_cell
def tests_weakref_does_not_add_when_inheriting_with_weakref():
"""
`weakref_slot=True` does not add a new __weakref__ slot when inheriting... | 3 | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_slots.py | test_slots_unpickle_after_attr_added | assert | numeric_literal | 72 | import pickle
import sys
import types
import weakref
from unittest import mock
import pytest
import attr
from attr._compat import PYPY, just_warn, make_set_closure_cell
def tests_weakref_does_not_add_when_inheriting_with_weakref():
"""
`weakref_slot=True` does not add a new __weakref__ slot when inheriting... | 2 | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_slots.py | test_cls_static | assert | variable | 31 | import pickle
import sys
import types
import weakref
from unittest import mock
import pytest
import attr
from attr._compat import PYPY, just_warn, make_set_closure_cell
class TestClosureCellRewriting:
def test_cls_static(self, slots):
"""
Slotted classes support proper closure cell rewriting f... | C | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_slots.py | test_cls_static | assert | variable | 39 | import pickle
import sys
import types
import weakref
from unittest import mock
import pytest
import attr
from attr._compat import PYPY, just_warn, make_set_closure_cell
class TestClosureCellRewriting:
def test_cls_static(self, slots):
"""
Slotted classes support proper closure cell rewriting f... | D | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_slots.py | test_inheritance_from_nonslots | assert | variable | 45 | import pickle
import sys
import types
import weakref
from unittest import mock
import pytest
import attr
from attr._compat import PYPY, just_warn, make_set_closure_cell
def test_inheritance_from_nonslots():
"""
Inheritance from a non-slotted class works.
Note that a slotted class inheriting from an or... | c2 | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
python-attrs/attrs | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | train | train | tests/test_slots.py | test_closure_cell_rewriting | assert | variable | 25 | import pickle
import sys
import types
import weakref
from unittest import mock
import pytest
import attr
from attr._compat import PYPY, just_warn, make_set_closure_cell
class TestClosureCellRewriting:
def test_closure_cell_rewriting(self):
"""
Slotted classes support proper closure cell rewriti... | C1 | 724bb9a6ca1570b40e933e8375e267421ae1be3f | 303 | v2_extractor_at_anchor |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.