__conf
is not used anywhere in the class StateWrapper
184
185
186class StateWrapper(MessageListener):
187 __conf: PlayerConfiguration188 __device: DeviceStateHandler
189 __player: Player
190 __session: Session
__device
is not used anywhere in the class StateWrapper
185
186class StateWrapper(MessageListener):
187 __conf: PlayerConfiguration
188 __device: DeviceStateHandler189 __player: Player
190 __session: Session
191
__player
is not used anywhere in the class StateWrapper
186class StateWrapper(MessageListener):
187 __conf: PlayerConfiguration
188 __device: DeviceStateHandler
189 __player: Player190 __session: Session
191
192 def __init__(self, session: Session, player: Player,
__session
is not used anywhere in the class StateWrapper
187 __conf: PlayerConfiguration
188 __device: DeviceStateHandler
189 __player: Player
190 __session: Session191
192 def __init__(self, session: Session, player: Player,
193 conf: PlayerConfiguration):
__state
is not used anywhere in the class Player
88 volume_max = 65536
89 __conf: PlayerConfiguration
90 __session: Session
91 __state: StateWrapper 92
93 def __init__(self, conf: PlayerConfiguration, session: Session):
94 self.__conf = conf
A private attribute defined in the class should be only accessible inside the class.
The names of attributes which are supposed to be public should not start with _
or __
.
This issue concerns that one or more private attributes have been declared but are nowhere used in the class.
It is recommended either to remove the unused private attributes or remove the __
prefix if it is intended to be accessed from outside the class.
Note:
A private attribute can not be accessed like other attributes.
Consider a class MyClass
with a private attribute: __x
.
Now, doing this will raise an AttributeError
:
c = MyClass()
print(c.__x)
But you can access the private attribute like this (which is not recommended, just for the record):
c = MyClass()
print(c._MyClass__x)
So, if you want to fix this issue: * Make sure the private attribute is being used in the class it is declared. * Rename the attribute to comply with the conventions (Check References). * If the attribute is unnecessary, remove it.
class Example:
def __init__(self, attr=10):
self.__private = "Placeholder"
self.attr = attr
def init_val(self):
print(f"class was initialised with the value: {self.attr}")
Here, the attribute self.__private
is unused and would not be accessible outside of the class directly.
_Note: This attribute would be removed during autofix._