Passed
Pull Request — main (#321)
by
unknown
02:02
created

_Component.with_attrs()   A

Complexity

Conditions 2

Size

Total Lines 17
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 17
rs 10
c 0
b 0
f 0
cc 2
nop 2
1
# Copyright Pincer 2021-Present
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
# Full MIT License can be found in `LICENSE` at the project root.
3
4
from __future__ import annotations
5
6
from copy import copy
7
8
from ...utils.api_object import APIObject
9
10
11
class _Component(APIObject):
12
    """Represents a message component with attributes that can be modified inline"""
13
14
    def with_attrs(self, **kwargs) -> _Component:
15
        """
16
        Modifies attributes are returns an object with these attributes.
17
18
        .. code-block:: python
19
20
            some_button.with_attrs(label="A new label")
21
22
        \\*\\*kwargs
23
            Attributes to modify and their values.
24
        """
25
        copied_obj = copy(self)
26
27
        for key, value in kwargs.items():
28
            setattr(copied_obj, key, value)
29
30
        return copied_obj
31