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

pincer.commands.components._component   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 11
dl 0
loc 31
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A _Component.with_attrs() 0 17 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