Skip to content

Commit

Permalink
Be consistent in calling slotted classes slotted
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Feb 25, 2019
1 parent 659aa48 commit 1fada3d
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ repos:
types: []

- repo: https://gitlab.com/pycqa/flake8
rev: '3.7.3'
rev: 3.7.6
hooks:
- id: flake8
language_version: python3.7

- repo: https://github.com/asottile/seed-isort-config
rev: v1.5.0
rev: v1.6.0
hooks:
- id: seed-isort-config

Expand Down
8 changes: 4 additions & 4 deletions docs/how-does-it-work.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Immutability

In order to give you immutability, ``attrs`` will attach a ``__setattr__`` method to your class that raises a :exc:`attr.exceptions.FrozenInstanceError` whenever anyone tries to set an attribute.

Depending on whether a class is a dict class or a slots class, ``attrs`` uses a different technique to circumvent that limitation in the ``__init__`` method.
Depending on whether a class is a dict class or a slotted class, ``attrs`` uses a different technique to circumvent that limitation in the ``__init__`` method.

Once constructed, frozen instances don't differ in any way from regular ones except that you cannot change its attributes.

Expand All @@ -66,10 +66,10 @@ Dict classes -- i.e. regular classes -- simply assign the value directly into th
The performance impact is negligible.


Slots Classes
+++++++++++++
Slotted Classes
+++++++++++++++

Slots classes are more complicated.
Slotted classes are more complicated.
Here it uses (an aggressively cached) :meth:`object.__setattr__` to set your attributes.
This is (still) slower than a plain assignment:

Expand Down
2 changes: 1 addition & 1 deletion src/attr/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def just_warn(*args, **kw):
"""
warnings.warn(
"Missing ctypes. Some features like bare super() or accessing "
"__class__ will not work with slots classes.",
"__class__ will not work with slotted classes.",
RuntimeWarning,
stacklevel=2,
)
Expand Down
4 changes: 2 additions & 2 deletions tests/strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ class HypClass:
c = attr.ib(default={'t': 1})
By default, all combinations of slots, frozen, and weakref_slot classes
will be generated. If `slots=True` is passed in, only slots classes will be
generated, and if `slots=False` is passed in, no slot classes will be
will be generated. If `slots=True` is passed in, only slotted classes will
be generated, and if `slots=False` is passed in, no slot classes will be
generated. The same applies to `frozen` and `weakref_slot`.
By default, some attributes will be private (i.e. prefixed with an
Expand Down
2 changes: 1 addition & 1 deletion tests/test_dunders.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ def assert_hash_code_not_cached_across_serialization(original):
round_tripped.foo_string = "something different"
assert original_hash != hash(round_tripped)

# Slots and non-slots classes implement __setstate__ differently,
# Slotted and dict classes implement __setstate__ differently,
# so we need to test both cases.
assert_hash_code_not_cached_across_serialization(
HashCacheSerializationTestCached()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_init_subclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
def test_init_subclass_vanilla(slots):
"""
`super().__init_subclass__` can be used if the subclass is not an attrs
class both with dict and slots classes.
class both with dict and slotted classes.
"""

@attr.s(slots=slots)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_make.py
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,7 @@ def fake_meth(self):
def test_weakref_setstate(self):
"""
__weakref__ is not set on in setstate because it's not writable in
slots classes.
slotted classes.
"""

@attr.s(slots=True)
Expand All @@ -1532,7 +1532,7 @@ class C(object):

def test_no_references_to_original(self):
"""
When subclassing a slots class, there are no stray references to the
When subclassing a slotted class, there are no stray references to the
original class.
"""

Expand Down
8 changes: 4 additions & 4 deletions tests/test_slots.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ def test_inheritance_from_nonslots():
"""
Inheritance from a non-slot class works.
Note that a slots class inheriting from an ordinary class loses most of the
benefits of slots classes, but it should still work.
Note that a slotted class inheriting from an ordinary class loses most of
the benefits of slotted classes, but it should still work.
"""

@attr.s(slots=True, hash=True)
Expand Down Expand Up @@ -168,7 +168,7 @@ class C2Slots(C1):

def test_nonslots_these():
"""
Enhancing a non-slots class using 'these' works.
Enhancing a dict class using 'these' works.
This will actually *replace* the class with another one, using slots.
"""
Expand Down Expand Up @@ -428,7 +428,7 @@ def test_missing_ctypes(self, monkeypatch):
assert __file__ == w.filename
assert (
"Missing ctypes. Some features like bare super() or accessing "
"__class__ will not work with slots classes.",
"__class__ will not work with slotted classes.",
) == w.message.args

assert just_warn is func
Expand Down

0 comments on commit 1fada3d

Please sign in to comment.