Passed
Push — main ( 87b586...6c0406 )
by Yohann
01:35
created

pincer.objects.user   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 39
dl 0
loc 76
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A User.premium() 0 4 1
A User.from_dict() 0 4 1
A User.__repr__() 0 2 1
A User.user() 0 3 1
1
# -*- coding: utf-8 -*-
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
# MIT License
3
#
4
# Copyright (c) 2021 Pincer
5
#
6
# Permission is hereby granted, free of charge, to any person obtaining
7
# a copy of this software and associated documentation files
8
# (the "Software"), to deal in the Software without restriction,
9
# including without limitation the rights to use, copy, modify, merge,
10
# publish, distribute, sublicense, and/or sell copies of the Software,
11
# and to permit persons to whom the Software is furnished to do so,
12
# subject to the following conditions:
13
#
14
# The above copyright notice and this permission notice shall be
15
# included in all copies or substantial portions of the Software.
16
#
17
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
from __future__ import annotations
25
26
from dataclasses import dataclass
27
from enum import Enum
28
from typing import Optional, Union
29
30
from websockets.typing import Data
31
32
33
class PremiumTypes(Enum):
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
34
    # TODO: Write documentation
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
35
    NONE = 0
36
    NITRO_CLASSIC = 1
37
    NITRO = 2
38
39
40
@dataclass
0 ignored issues
show
best-practice introduced by
Too many instance attributes (16/7)
Loading history...
introduced by
Missing class docstring
Loading history...
41
class User:
42
    # TODO: Write documentation
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
43
    id: int
1 ignored issue
show
Coding Style Naming introduced by
Attribute name "id" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
44
    flags: int
45
    username: str
46
    discriminator: str
47
    bot: Optional[bool] = False
48
    email: Optional[str] = None
49
    banner: Optional[str] = None
50
    locale: Optional[str] = None
51
    avatar: Optional[str] = None
52
    system: Optional[bool] = False
53
    accent_color: Optional[int] = 0
54
    public_flags: Optional[int] = 0
55
    verified: Optional[bool] = False
56
    avatar_url: Optional[str] = None
57
    mfa_enabled: Optional[bool] = False
58
    premium_type: Optional[int] = 0
59
60
    @classmethod
61
    def from_dict(cls, data: Data[str, Union[str, bool, int]]) -> User:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
62
        # TODO: Write documentation
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
63
        return cls(**data)
64
65
    @property
66
    def premium(self) -> PremiumTypes:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
67
        # TODO: Write documentation
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
68
        return PremiumTypes(self.premium_type)
69
70
    @property
71
    def user(self) -> str:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
72
        return self.username + '#' + self.discriminator
73
74
    def __repr__(self):
75
        return self.user
76