GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — develop (#238)
by
unknown
01:21
created

Player.address_and_port()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
import weakref
2
3
from enum import IntEnum, unique, Enum
0 ignored issues
show
Unused Code introduced by
Unused IntEnum imported from enum
Loading history...
4
5
from .abc.base_player import BasePlayer
0 ignored issues
show
Bug introduced by
The name base_player does not seem to exist in module abc.
Loading history...
Configuration introduced by
The import abc.base_player could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
6
7
@unique
8
class PlayerState(Enum):
9
    IDLE = 1,
10
    PLAYING = 2,
11
    HOSTING = 3,
12
    JOINING = 4,
13
    SEARCHING_LADDER = 5,
14
15
class Player(BasePlayer):
16
    """
17
    Standard player object used for representing signed-in players.
18
19
    In the context of a game, the Game object holds game-specific
20
    information about players.
21
    """
22
    def __init__(self, login=None, session=0, ip=None, id=0,
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in id.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
23
                 global_rating=None, ladder_rating=None, clan=None, numGames=0, permissionGroup=0, lobby_connection=None):
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (122/120).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
24
        super().__init__(id, login)
25
26
        # The id of the user in the `login` table of the database.
27
        self.session = session
28
        self.ip = ip
29
30
        if global_rating is None:
31
            global_rating = (1500, 500)
32
        if ladder_rating is None:
33
            ladder_rating = (1500, 500)
34
        self.global_rating = global_rating
35
        self.ladder_rating = ladder_rating
36
37
        #social
38
        self.avatar = None
39
        self.clan = clan
40
        self.country = None
41
42
        self.friends = set()
43
        self.foes = set()
44
45
        self.league = None
46
47
        self.admin = permissionGroup >= 2
48
        self.mod = permissionGroup >= 1
49
        
50
        self.numGames = numGames
51
52
        self.state = PlayerState.IDLE
53
54
        self.expandLadder = 0
55
        self.faction = 1
56
57
        self._lobby_connection = lambda: None
58
        if lobby_connection is not None:
59
            self.lobby_connection = lobby_connection
60
61
        self._game = lambda: None
62
        self._game_connection = lambda: None
63
64
    @property
65
    def lobby_connection(self) -> "LobbyConnection":
66
        """
67
        Weak reference to the LobbyConnection of this player
68
        """
69
        return self._lobby_connection()
70
71
    @lobby_connection.setter
72
    def lobby_connection(self, value: "LobbyConnection"):
73
        self._lobby_connection = weakref.ref(value)
74
75
    @property
76
    def game(self):
77
        """
78
        Weak reference to the Game object that this player wants to join or is currently in
79
        """
80
        return self._game()
81
82
    @game.setter
83
    def game(self, value):
84
        self._game = weakref.ref(value)
85
86
    @game.deleter
87
    def game(self):
88
        self._game = lambda: None
89
90
    @property
91
    def game_connection(self):
92
        """
93
        Weak reference to the GameConnection object for this player
94
        :return:
95
        """
96
        return self._game_connection()
97
98
    @game_connection.setter
99
    def game_connection(self, value):
100
        self._game_connection = weakref.ref(value)
101
102
    @game_connection.deleter
103
    def game_connection(self):
104
        self._game_connection = lambda: None
105
106
    @property
107
    def in_game(self):
108
        return self.game is not None
109
110
    def to_dict(self):
111
        """
112
        Return a dictionary representing this player object
113
        :return:
114
        """
115
        def filter_none(t):
116
            _, v = t
117
            return v is not None
118
        return dict(filter(filter_none, (
119
            ('id', self.id),
0 ignored issues
show
Bug introduced by
The Instance of Player does not seem to have a member named id.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
120
            ('login', self.login),
0 ignored issues
show
Bug introduced by
The Instance of Player does not seem to have a member named login.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
121
            ('global_rating', self.global_rating),
122
            ('ladder_rating', self.ladder_rating),
123
            ('number_of_games', self.numGames),
124
            ('avatar', self.avatar),
125
            ('country', self.country),
126
            ('clan', self.clan)
127
        )))
128
129
    def __str__(self):
130
        return "Player({}, {}, {}, {})".format(self.login, self.id, self.global_rating, self.ladder_rating)
0 ignored issues
show
Bug introduced by
The Instance of Player does not seem to have a member named login.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
Bug introduced by
The Instance of Player does not seem to have a member named id.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
131
132
    def __repr__(self):
133
        return self.__str__()
134
135
    def __hash__(self):
136
        return self.id
0 ignored issues
show
Bug introduced by
The Instance of Player does not seem to have a member named id.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
137
138
    def __eq__(self, other):
139
        if not isinstance(other, BasePlayer):
140
            return False
141
        else:
142
            return self.id == other.id
0 ignored issues
show
Bug introduced by
The Instance of Player does not seem to have a member named id.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
143