Skip to content

Commit

Permalink
Pylint cleanups (home-assistant-libs#201)
Browse files Browse the repository at this point in the history
* Clean up pylintrc

Fix section order and option placement, remove duplicated defaults and
unneeded disables.

* pylint 2 useless-object-inheritance fixes

* pylint 2 useless-import-alias fix

* Add a disable for pylint 2 consider-using-dict-comprehension

Can't come up with a cleaner way to accomplish this particular case
using a dict comprehension right now.

* Remove unneeded pylint inline disables
  • Loading branch information
scop authored and balloob committed Jul 16, 2018
1 parent 83a5482 commit f2febc1
Show file tree
Hide file tree
Showing 36 changed files with 14 additions and 50 deletions.
4 changes: 2 additions & 2 deletions netdisco/daikin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Daikin device discovery."""
import socket

# pylint: disable=unused-import, import-error, no-name-in-module
try:
# Py2
from urlparse import unquote # noqa
Expand All @@ -20,7 +19,7 @@
DISCOVERY_TIMEOUT = timedelta(seconds=2)


class Daikin(object):
class Daikin:
"""Base class to discover Daikin devices."""

def __init__(self):
Expand Down Expand Up @@ -53,6 +52,7 @@ def update(self):
try:
data, (address, _) = sock.recvfrom(1024)

# pylint: disable=consider-using-dict-comprehension
entry = dict([e.split('=')
for e in data.decode("UTF-8").split(',')])

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/DLNA.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from . import SSDPDiscoverable


# pylint: disable=too-few-public-methods
class Discoverable(SSDPDiscoverable):
"""Add support for discovering DLNA services."""

Expand Down
3 changes: 1 addition & 2 deletions netdisco/discoverables/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
ATTR_PROPERTIES, ATTR_MANUFACTURER, ATTR_UDN, ATTR_UPNP_DEVICE_TYPE)


class BaseDiscoverable(object):
class BaseDiscoverable:
"""Base class for discoverable services or device types."""

def is_discovered(self):
Expand All @@ -28,7 +28,6 @@ def info_from_entry(self, entry):
"""Return an object with important info from the entry."""
return entry

# pylint: disable=no-self-use
def get_entries(self):
"""Return all the discovered entries."""
raise NotImplementedError()
Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/apple_tv.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from ..const import ATTR_NAME, ATTR_PROPERTIES


# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for Apple TV devices."""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/arduino.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from . import MDNSDiscoverable


# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering Arduino devices."""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
ATTR_HOST, ATTR_PORT, ATTR_HOSTNAME, ATTR_PROPERTIES)


# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering Axis devices."""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/bluesound.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from . import MDNSDiscoverable


# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering Bluesound service."""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/bose_soundtouch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from . import MDNSDiscoverable


# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering Bose SoundTouch devices."""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/freebox.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from . import MDNSDiscoverable


# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering Freebox routers."""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/fritzbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from . import SSDPDiscoverable


# pylint: disable=too-few-public-methods
class Discoverable(SSDPDiscoverable):
"""Add support for discovering AVM FRITZ devices."""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/google_cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from . import MDNSDiscoverable


# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering Google Cast platform devices."""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/hass_ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from . import MDNSDiscoverable


# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering the Home Assistant iOS app."""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/home_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from . import MDNSDiscoverable


# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering Home Assistant instances."""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/homekit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from ..const import ATTR_NAME


# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering HomeKit devices."""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/ikea_tradfri.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from . import MDNSDiscoverable


# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering Ikea Tradfri devices."""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/kodi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from . import MDNSDiscoverable


# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering Kodi."""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/lutron.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from . import MDNSDiscoverable


# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering Lutron Caseta Smart Bridge
and Smart Bridge Pro devices."""
Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/nanoleaf_aurora.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from . import MDNSDiscoverable


# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering Nanoleaf Aurora devices."""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/openhome.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from . import SSDPDiscoverable


# pylint: disable=too-few-public-methods
class Discoverable(SSDPDiscoverable):
"""Add support for discovering Openhome compliant devices."""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/panasonic_viera.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from . import SSDPDiscoverable


# pylint: disable=too-few-public-methods
class Discoverable(SSDPDiscoverable):
"""Add support for discovering Viera TV devices."""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/sabnzbd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from . import MDNSDiscoverable


# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering SABnzbd."""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/sonos.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from . import SSDPDiscoverable


# pylint: disable=too-few-public-methods
class Discoverable(SSDPDiscoverable):
"""Add support for discovering Sonos devices."""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/spotify_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from . import MDNSDiscoverable


# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering Spotify Connect service."""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/tivo_dvr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from . import MDNSDiscoverable


# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering TiVo Remote Protocol service."""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/volumio.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from . import MDNSDiscoverable


# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering Volumio."""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/webos_tv.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from . import SSDPDiscoverable


# pylint: disable=too-few-public-methods
class Discoverable(SSDPDiscoverable):
"""Add support for discovering LG WebOS TV devices."""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/xiaomi_gw.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from ..const import ATTR_MAC_ADDRESS, ATTR_PROPERTIES


# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering Xiaomi Gateway"""

Expand Down
1 change: 0 additions & 1 deletion netdisco/discoverables/yeelight.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
DEVICE_NAME_PREFIX = 'yeelink-light-'


# pylint: disable=too-few-public-methods
class Discoverable(MDNSDiscoverable):
"""Add support for discovering Yeelight."""

Expand Down
2 changes: 1 addition & 1 deletion netdisco/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
_LOGGER = logging.getLogger(__name__)


class NetworkDiscovery(object):
class NetworkDiscovery:
"""Scan the network for devices.
mDNS scans in a background thread.
Expand Down
3 changes: 1 addition & 2 deletions netdisco/gdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import struct


class GDM(object):
class GDM:
"""Base class to discover GDM services."""

def __init__(self):
Expand Down Expand Up @@ -95,7 +95,6 @@ def update(self):

def main():
"""Test GDM discovery."""
# pylint: disable=invalid-name
from pprint import pprint

gdm = GDM()
Expand Down
3 changes: 1 addition & 2 deletions netdisco/lms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
DEFAULT_DISCOVERY_TIMEOUT = 2


class LMS(object):
class LMS:
"""Base class to discover Logitech Media servers."""

def __init__(self):
Expand Down Expand Up @@ -67,7 +67,6 @@ def main():
"""Test LMS discovery."""
from pprint import pprint

# pylint: disable=invalid-name
lms = LMS()

pprint("Scanning for Logitech Media Servers...")
Expand Down
2 changes: 1 addition & 1 deletion netdisco/mdns.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import zeroconf


class MDNS(object):
class MDNS:
"""Base class to discover mDNS services."""

def __init__(self):
Expand Down
6 changes: 3 additions & 3 deletions netdisco/ssdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import socket
import logging
from datetime import datetime, timedelta
import xml.etree.ElementTree as ElementTree
from xml.etree import ElementTree

import requests

Expand All @@ -27,7 +27,7 @@
ST_ROOTDEVICE = "upnp:rootdevice"


class SSDP(object):
class SSDP:
"""Control the scanning of uPnP devices and services and caches output."""

def __init__(self):
Expand Down Expand Up @@ -96,7 +96,7 @@ def remove_expired(self):
if not entry.is_expired]


class UPNPEntry(object):
class UPNPEntry:
"""Found uPnP entry."""

DESCRIPTION_CACHE = {'_NO_LOCATION': {}}
Expand Down
2 changes: 1 addition & 1 deletion netdisco/tellstick.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
DISCOVERY_TIMEOUT = timedelta(seconds=2)


class Tellstick(object):
class Tellstick:
"""Base class to discover Tellstick devices."""

def __init__(self):
Expand Down
1 change: 0 additions & 1 deletion netdisco/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def interface_addresses(family=netifaces.AF_INET):
Gathering of addresses which are bound to a local interface that has
broadcast (and probably multicast) capability.
"""
# pylint: disable=no-member
return [addr['addr']
for i in netifaces.interfaces()
for addr in netifaces.ifaddresses(i).get(family) or []
Expand Down
12 changes: 3 additions & 9 deletions pylintrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
[BASIC]
module-naming-style=snake_case
module-rgx=(([a-z_][a-z0-9_]*)|(?:DLNA))$

[MASTER]
reports=no
disable=duplicate-code

disable=locally-disabled,duplicate-code

[EXCEPTIONS]
overgeneral-exceptions=Exception
[BASIC]
module-rgx=(([a-z_][a-z0-9_]*)|(?:DLNA))$

0 comments on commit f2febc1

Please sign in to comment.