Skip to content

PyoMutableSet

Bases: PyoSet[T], MutableSet[T]


              flowchart TD
              pyochain.abc._mutable_set.PyoMutableSet[PyoMutableSet]
              pyochain.abc._set.PyoSet[PyoSet]
              pyochain.abc._collection.PyoCollection[PyoCollection]
              pyochain.abc._iterable.PyoIterable[PyoIterable]
              pyochain.abc._collection.PyoContainer[PyoContainer]
              pyochain.abc._collection.PyoSized[PyoSized]
              pyochain.abc._mixins.Checkable[Checkable]
              pyochain.abc._mixins.Fluent[Fluent]
              pyochain.abc._mixins.Pipe[Pipe]
              pyochain.abc._mixins.Tap[Tap]

                              pyochain.abc._set.PyoSet --> pyochain.abc._mutable_set.PyoMutableSet
                                pyochain.abc._collection.PyoCollection --> pyochain.abc._set.PyoSet
                                pyochain.abc._iterable.PyoIterable --> pyochain.abc._collection.PyoCollection
                                pyochain.abc._mixins.Checkable --> pyochain.abc._iterable.PyoIterable
                
                pyochain.abc._mixins.Fluent --> pyochain.abc._iterable.PyoIterable
                                pyochain.abc._mixins.Pipe --> pyochain.abc._mixins.Fluent
                
                pyochain.abc._mixins.Tap --> pyochain.abc._mixins.Fluent
                


                pyochain.abc._collection.PyoContainer --> pyochain.abc._collection.PyoCollection
                                pyochain.abc._mixins.Checkable --> pyochain.abc._collection.PyoContainer
                

                pyochain.abc._collection.PyoSized --> pyochain.abc._collection.PyoCollection
                                pyochain.abc._mixins.Checkable --> pyochain.abc._collection.PyoSized
                





              click pyochain.abc._mutable_set.PyoMutableSet href "" "pyochain.abc._mutable_set.PyoMutableSet"
              click pyochain.abc._set.PyoSet href "" "pyochain.abc._set.PyoSet"
              click pyochain.abc._collection.PyoCollection href "" "pyochain.abc._collection.PyoCollection"
              click pyochain.abc._iterable.PyoIterable href "" "pyochain.abc._iterable.PyoIterable"
              click pyochain.abc._collection.PyoContainer href "" "pyochain.abc._collection.PyoContainer"
              click pyochain.abc._collection.PyoSized href "" "pyochain.abc._collection.PyoSized"
              click pyochain.abc._mixins.Checkable href "" "pyochain.abc._mixins.Checkable"
              click pyochain.abc._mixins.Fluent href "" "pyochain.abc._mixins.Fluent"
              click pyochain.abc._mixins.Pipe href "" "pyochain.abc._mixins.Pipe"
              click pyochain.abc._mixins.Tap href "" "pyochain.abc._mixins.Tap"
            

ABCs for read-only and mutable sets.

Source code in pyochain/abc/_mutable_set.pyi
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
class PyoMutableSet[T](PyoSet[T], MutableSet[T]):  # pyright: ignore[reportImplicitAbstractClass]
    """ABCs for read-only and mutable sets."""
    # TODO: check logic of typing and impl for vanilla collections.abc
    # Pyo3 forces incompatible implementations of those dunders -> they return `None` instead of `Self`.
    # However, typing-wise, they must return `Self`, otherwise type checkers will complain about unknown return types.
    @override
    def __ior__(self, it: AbstractSet[T], /) -> Self: ...
    @override
    def __iand__(self, it: AbstractSet[Any], /) -> Self: ...
    @override
    def __ixor__(self, it: AbstractSet[T], /) -> Self: ...
    @override
    def __isub__(self, it: AbstractSet[Any], /) -> Self: ...
    @abstractmethod
    @override
    def add(self, value: T, /) -> None: ...
    @abstractmethod
    @override
    def discard(self, value: T, /) -> None: ...

    # Mixin methods
    @override
    def clear(self) -> None:
        """Remove all elements from this set.

        Example:
            ```python
            from pyochain import SetMut

            s = SetMut(1, 2, 3)
            s.clear()
            assert s.len() == 0
            ```
        """

    @override
    def pop(self) -> T: ...
    @override
    def remove(self, value: T, /) -> None: ...

clear()

Remove all elements from this set.

Example
from pyochain import SetMut

s = SetMut(1, 2, 3)
s.clear()
assert s.len() == 0
Source code in pyochain/abc/_mutable_set.pyi
29
30
31
32
33
34
35
36
37
38
39
40
41
@override
def clear(self) -> None:
    """Remove all elements from this set.

    Example:
        ```python
        from pyochain import SetMut

        s = SetMut(1, 2, 3)
        s.clear()
        assert s.len() == 0
        ```
    """