Skip to content

Commit

Permalink
Fix pylint E0203 (access-member-before-definition) wrongly detected
Browse files Browse the repository at this point in the history
It seems that pylint (v2.1.x) for python version 3.6 has some troubles when dealing with python3's f-string (the affected lines caused no troubles in python 3.7.x). The failure appears when accessing class variables set at __init__ method and trying to use the f-string feature, using those recently defined class variables. The problem is solved by using directly the passed variable via args instead of the class variable.

References: pylint-dev/pylint#2315
  • Loading branch information
opacam committed Nov 10, 2018
1 parent ab836d6 commit a687512
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
8 changes: 4 additions & 4 deletions coherence/upnp/core/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def __init__(self, service_type, service_id, location, control_url,
presentation_url.encode('ascii') if presentation_url else None
self.scpd_url = scpd_url if isinstance(scpd_url, bytes) else \
scpd_url.encode('ascii') if scpd_url else None
self.device = device # pylint: disable=access-member-before-definition
self.device = device
self._actions = {}
self._variables = {0: {}}
self._var_subscribers = {}
Expand All @@ -161,7 +161,7 @@ def __init__(self, service_type, service_id, location, control_url,
self.url_base = f'{parsed[0]}://{parsed[1]}'.encode('ascii')

self.parse_actions()
self.info(f'{self.device.friendly_name} {self.service_type} '
self.info(f'{device.friendly_name} {self.service_type} '
f'{self.id} initialized')

def as_tuples(self):
Expand Down Expand Up @@ -557,7 +557,7 @@ class ServiceServer(log.LogAble):
def __init__(self, id, version, backend):
log.LogAble.__init__(self)
self.id = id
self.version = version # pylint: disable=access-member-before-definition # noqa
self.version = version
self.backend = backend
self.debug(f'ServiceServer.__init__: {id} '
f'[version: {version}, backend: {backend}]')
Expand All @@ -567,7 +567,7 @@ def __init__(self, id, version, backend):
self.id_namespace = 'upnp-org'

self.service_type = \
f'urn:{self.namespace}:service:{id}:{int(self.version):d}'
f'urn:{self.namespace}:service:{id}:{int(version):d}'
self.debug(f'\t-service_type: {self.service_type}')

self.scpdXML = None
Expand Down
5 changes: 2 additions & 3 deletions coherence/upnp/devices/internet_gateway_device_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ def __init__(self, device):
self.register_event(
'device_client_detection_completed',
)
self.device = device # pylint: disable=access-member-before-definition

self.device = device
self.device.bind(
embedded_device_client_detection_completed=self.embedded_device_notified) # noqa

Expand All @@ -68,7 +67,7 @@ def __init__(self, device):
f' specification [error: {e}]')
raise

self.info(f'InternetGatewayDevice {self.device.get_friendly_name()}')
self.info(f'InternetGatewayDevice {device.get_friendly_name()}')

def remove(self):
self.info('removal of InternetGatewayDeviceClient started')
Expand Down
4 changes: 2 additions & 2 deletions coherence/upnp/devices/media_renderer_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(self, device):
'device_client_detection_completed',
)

self.device = device # pylint: disable=access-member-before-definition
self.device = device
self.device.bind(device_service_notified=self.service_notified)
self.device_type = self.device.get_friendly_device_type()

Expand All @@ -78,7 +78,7 @@ def __init__(self, device):
self.av_transport = AVTransportClient(service)
if service.detection_completed:
self.service_notified(service)
self.info(f'MediaRenderer {self.device.get_friendly_name()}')
self.info(f'MediaRenderer {device.get_friendly_name()}')
if self.rendering_control:
self.info('RenderingControl available')
'''
Expand Down
4 changes: 2 additions & 2 deletions coherence/upnp/devices/media_server_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __init__(self, device):
'device_client_detection_completed',
)

self.device = device # pylint: disable=access-member-before-definition
self.device = device
self.device.bind(device_service_notified=self.service_notified)
self.device_type = self.device.get_friendly_device_type()

Expand All @@ -85,7 +85,7 @@ def __init__(self, device):
if service.detection_completed:
self.service_notified(service)

self.info(f'MediaServer {self.device.get_friendly_name()}')
self.info(f'MediaServer {device.get_friendly_name()}')
if self.content_directory:
self.info('ContentDirectory available')
else:
Expand Down
4 changes: 2 additions & 2 deletions coherence/upnp/devices/wan_connection_device_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(self, device):
self.register_event(
'embedded_device_client_detection_completed',
)
self.device = device # pylint: disable=access-member-before-definition
self.device = device
self.device.bind(service_notified=self.service_notified)
self.device_type = self.device.get_friendly_device_type()

Expand All @@ -67,7 +67,7 @@ def __init__(self, device):
if service.get_type() in [
'urn:schemas-upnp-org:service:WANPPPConnection:1']:
self.wan_ppp_connection = WANPPPConnectionClient(service)
self.info(f'WANConnectionDevice {self.device.get_friendly_name()}')
self.info(f'WANConnectionDevice {device.get_friendly_name()}')
if self.wan_ip_connection:
self.info('WANIPConnection service available')
if self.wan_ppp_connection:
Expand Down
4 changes: 2 additions & 2 deletions coherence/upnp/devices/wan_device_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self, device):
'embedded_device_client_detection_completed',
)

self.device = device # pylint: disable=access-member-before-definition
self.device = device
self.device.bind(
embedded_device_client_detection_completed=self.embedded_device_notified, # noqa
service_notified=self.service_notified
Expand Down Expand Up @@ -94,7 +94,7 @@ def __init__(self, device):
self.wan_common_interface_connection = \
WANCommonInterfaceConfigClient(service)

self.info(f'WANDevice {self.device.get_friendly_name()}')
self.info(f'WANDevice {device.get_friendly_name()}')

def remove(self):
self.info('removal of WANDeviceClient started')
Expand Down

0 comments on commit a687512

Please sign in to comment.