diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 18f244790..a35fff26c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/docs/how-does-it-work.rst b/docs/how-does-it-work.rst index 61423b008..1de7cecf6 100644 --- a/docs/how-does-it-work.rst +++ b/docs/how-does-it-work.rst @@ -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. @@ -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: diff --git a/src/attr/_compat.py b/src/attr/_compat.py index 1a1db5734..9a99dcd96 100644 --- a/src/attr/_compat.py +++ b/src/attr/_compat.py @@ -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, ) diff --git a/tests/strategies.py b/tests/strategies.py index 1d9894590..d66a2c1e1 100644 --- a/tests/strategies.py +++ b/tests/strategies.py @@ -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 diff --git a/tests/test_dunders.py b/tests/test_dunders.py index b9337b2eb..545a2b3a4 100644 --- a/tests/test_dunders.py +++ b/tests/test_dunders.py @@ -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() diff --git a/tests/test_init_subclass.py b/tests/test_init_subclass.py index 3809e843a..2748655a0 100644 --- a/tests/test_init_subclass.py +++ b/tests/test_init_subclass.py @@ -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) diff --git a/tests/test_make.py b/tests/test_make.py index d02c12420..a0597f16e 100644 --- a/tests/test_make.py +++ b/tests/test_make.py @@ -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) @@ -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. """ diff --git a/tests/test_slots.py b/tests/test_slots.py index f2caca00d..7e78eb67e 100644 --- a/tests/test_slots.py +++ b/tests/test_slots.py @@ -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) @@ -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. """ @@ -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