Skip to content

Commit

Permalink
cq: Run pylint from tox (#979)
Browse files Browse the repository at this point in the history
In the past, pylint was run by tox but for some reason I removed it. Not
sure why. This commits adds pylint to tox again and fixes a few issues.
  • Loading branch information
postlund authored Mar 2, 2021
1 parent 7464cb7 commit 1e1922e
Show file tree
Hide file tree
Showing 32 changed files with 249 additions and 166 deletions.
1 change: 1 addition & 0 deletions docs/api/pyatv/const.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ <h1 class="title">Module <code>pyatv.const</code></h1>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;Constants used in the public API.&#34;&#34;&#34;
# pylint: disable=invalid-name

from enum import Enum

Expand Down
52 changes: 27 additions & 25 deletions docs/api/pyatv/interface.html
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ <h1 class="title">Module <code>pyatv.interface</code></h1>
raise exceptions.NotSupportedError()


class RemoteControl(ABC): # pylint: disable=too-many-public-methods
class RemoteControl(ABC):
&#34;&#34;&#34;Base class for API used to control an Apple TV.&#34;&#34;&#34;

# pylint: disable=invalid-name
Expand Down Expand Up @@ -650,7 +650,7 @@ <h1 class="title">Module <code>pyatv.interface</code></h1>
position: Optional[int] = None,
shuffle: Optional[const.ShuffleState] = None,
repeat: Optional[const.RepeatState] = None,
hash: Optional[str] = None,
hash: Optional[str] = None, # pylint: disable=redefined-builtin
) -&gt; None:
&#34;&#34;&#34;Initialize a new Playing instance.&#34;&#34;&#34;
self._media_type = media_type
Expand Down Expand Up @@ -883,6 +883,7 @@ <h1 class="title">Module <code>pyatv.interface</code></h1>

def __init__(self, loop: asyncio.AbstractEventLoop):
&#34;&#34;&#34;Initialize a new PushUpdater.&#34;&#34;&#34;
super().__init__()
self.loop = loop
self._previous_state: Optional[Playing] = None

Expand Down Expand Up @@ -989,7 +990,7 @@ <h1 class="title">Module <code>pyatv.interface</code></h1>
build_number: Optional[str],
model: const.DeviceModel,
mac: Optional[str],
) -&gt; None: # pylint: disable=too-many-arguments # noqa
) -&gt; None:
&#34;&#34;&#34;Initialize a new DeviceInfo instance.&#34;&#34;&#34;
self._os = os
self._version = version
Expand Down Expand Up @@ -1050,17 +1051,17 @@ <h1 class="title">Module <code>pyatv.interface</code></h1>
&#34;&#34;&#34;Base class for supported feature functionality.&#34;&#34;&#34;

@abstractmethod
def get_feature(self, feature: FeatureName) -&gt; FeatureInfo:
def get_feature(self, feature_name: FeatureName) -&gt; FeatureInfo:
&#34;&#34;&#34;Return current state of a feature.&#34;&#34;&#34;
raise NotImplementedError()

def all_features(self, include_unsupported=False) -&gt; Dict[FeatureName, FeatureInfo]:
&#34;&#34;&#34;Return state of all features.&#34;&#34;&#34;
features = {} # type: Dict[FeatureName, FeatureInfo]
for name in FeatureName:
feature = self.get_feature(name)
if feature.state != FeatureState.Unsupported or include_unsupported:
features[name] = feature
info = self.get_feature(name)
if info.state != FeatureState.Unsupported or include_unsupported:
features[name] = info
return features

def in_state(
Expand All @@ -1075,9 +1076,9 @@ <h1 class="title">Module <code>pyatv.interface</code></h1>
in one of the listed states.
&#34;&#34;&#34;
for name in feature_names:
feature = self.get_feature(name)
info = self.get_feature(name)
expected_states = states if isinstance(states, list) else [states]
if feature.state not in expected_states:
if info.state not in expected_states:
return False
return True

Expand Down Expand Up @@ -1645,7 +1646,7 @@ <h3>Methods</h3>
build_number: Optional[str],
model: const.DeviceModel,
mac: Optional[str],
) -&gt; None: # pylint: disable=too-many-arguments # noqa
) -&gt; None:
&#34;&#34;&#34;Initialize a new DeviceInfo instance.&#34;&#34;&#34;
self._os = os
self._version = version
Expand Down Expand Up @@ -1880,17 +1881,17 @@ <h3>Instance variables</h3>
&#34;&#34;&#34;Base class for supported feature functionality.&#34;&#34;&#34;

@abstractmethod
def get_feature(self, feature: FeatureName) -&gt; FeatureInfo:
def get_feature(self, feature_name: FeatureName) -&gt; FeatureInfo:
&#34;&#34;&#34;Return current state of a feature.&#34;&#34;&#34;
raise NotImplementedError()

def all_features(self, include_unsupported=False) -&gt; Dict[FeatureName, FeatureInfo]:
&#34;&#34;&#34;Return state of all features.&#34;&#34;&#34;
features = {} # type: Dict[FeatureName, FeatureInfo]
for name in FeatureName:
feature = self.get_feature(name)
if feature.state != FeatureState.Unsupported or include_unsupported:
features[name] = feature
info = self.get_feature(name)
if info.state != FeatureState.Unsupported or include_unsupported:
features[name] = info
return features

def in_state(
Expand All @@ -1905,9 +1906,9 @@ <h3>Instance variables</h3>
in one of the listed states.
&#34;&#34;&#34;
for name in feature_names:
feature = self.get_feature(name)
info = self.get_feature(name)
expected_states = states if isinstance(states, list) else [states]
if feature.state not in expected_states:
if info.state not in expected_states:
return False
return True</code></pre>
</details>
Expand Down Expand Up @@ -1935,14 +1936,14 @@ <h3>Methods</h3>
&#34;&#34;&#34;Return state of all features.&#34;&#34;&#34;
features = {} # type: Dict[FeatureName, FeatureInfo]
for name in FeatureName:
feature = self.get_feature(name)
if feature.state != FeatureState.Unsupported or include_unsupported:
features[name] = feature
info = self.get_feature(name)
if info.state != FeatureState.Unsupported or include_unsupported:
features[name] = info
return features</code></pre>
</details>
</dd>
<dt id="pyatv.interface.Features.get_feature"><code class="name flex">
<span>def <span class="ident">get_feature</span></span>(<span>self, feature<a title="pyatv.const.FeatureName" href="const#pyatv.const.FeatureName">FeatureName</a>) -> <a title="pyatv.interface.FeatureInfo" href="#pyatv.interface.FeatureInfo">FeatureInfo</a></span>
<span>def <span class="ident">get_feature</span></span>(<span>self, feature_name<a title="pyatv.const.FeatureName" href="const#pyatv.const.FeatureName">FeatureName</a>) -> <a title="pyatv.interface.FeatureInfo" href="#pyatv.interface.FeatureInfo">FeatureInfo</a></span>
</code></dt>
<dd>
<section class="desc"><p>Return current state of a feature.</p></section>
Expand All @@ -1951,7 +1952,7 @@ <h3>Methods</h3>
<span>Expand source code</span>
</summary>
<pre><code class="python">@abstractmethod
def get_feature(self, feature: FeatureName) -&gt; FeatureInfo:
def get_feature(self, feature_name: FeatureName) -&gt; FeatureInfo:
&#34;&#34;&#34;Return current state of a feature.&#34;&#34;&#34;
raise NotImplementedError()</code></pre>
</details>
Expand Down Expand Up @@ -1980,9 +1981,9 @@ <h3>Methods</h3>
in one of the listed states.
&#34;&#34;&#34;
for name in feature_names:
feature = self.get_feature(name)
info = self.get_feature(name)
expected_states = states if isinstance(states, list) else [states]
if feature.state not in expected_states:
if info.state not in expected_states:
return False
return True</code></pre>
</details>
Expand Down Expand Up @@ -2378,7 +2379,7 @@ <h3>Methods</h3>
position: Optional[int] = None,
shuffle: Optional[const.ShuffleState] = None,
repeat: Optional[const.RepeatState] = None,
hash: Optional[str] = None,
hash: Optional[str] = None, # pylint: disable=redefined-builtin
) -&gt; None:
&#34;&#34;&#34;Initialize a new Playing instance.&#34;&#34;&#34;
self._media_type = media_type
Expand Down Expand Up @@ -2926,6 +2927,7 @@ <h3>Methods</h3>

def __init__(self, loop: asyncio.AbstractEventLoop):
&#34;&#34;&#34;Initialize a new PushUpdater.&#34;&#34;&#34;
super().__init__()
self.loop = loop
self._previous_state: Optional[Playing] = None

Expand Down Expand Up @@ -3054,7 +3056,7 @@ <h3>Inherited members</h3>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class RemoteControl(ABC): # pylint: disable=too-many-public-methods
<pre><code class="python">class RemoteControl(ABC):
&#34;&#34;&#34;Base class for API used to control an Apple TV.&#34;&#34;&#34;

# pylint: disable=invalid-name
Expand Down
6 changes: 3 additions & 3 deletions pyatv/airplay/pairing.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ def has_paired(self):
"""If a successful pairing has been performed."""
return self._has_paired

def begin(self):
async def begin(self):
"""Start pairing process."""
_LOGGER.debug(
"Starting AirPlay pairing with credentials %s", self.auth_data.credentials
)
self.pairing_complete = False
return error_handler(
self._has_paired = False
return await error_handler(
self.authenticator.start_authentication, exceptions.PairingError
)

Expand Down
1 change: 1 addition & 0 deletions pyatv/airplay/srp.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def __init__(self):
"""Initialize a new SRPAuthHandler."""
self.seed = None
self.session = None
self._public_bytes = None
self._auth_private = None
self._auth_public = None
self._verify_private = None
Expand Down
1 change: 1 addition & 0 deletions pyatv/const.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Constants used in the public API."""
# pylint: disable=invalid-name

from enum import Enum

Expand Down
18 changes: 10 additions & 8 deletions pyatv/dmap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,19 +549,21 @@ def __init__(self, config: conf.AppleTV, apple_tv: BaseDmapAppleTV) -> None:
self.config = config
self.apple_tv = apple_tv

def get_feature(self, feature: FeatureName) -> FeatureInfo:
def get_feature( # pylint: disable=too-many-return-statements
self, feature_name: FeatureName
) -> FeatureInfo:
"""Return current state of a feature."""
if feature in _AVAILABLE_FEATURES:
if feature_name in _AVAILABLE_FEATURES:
return FeatureInfo(state=FeatureState.Available)
if feature in _UNKNOWN_FEATURES:
if feature_name in _UNKNOWN_FEATURES:
return FeatureInfo(state=FeatureState.Unknown)
if feature in _FIELD_FEATURES:
return FeatureInfo(state=self._is_available(_FIELD_FEATURES[feature]))
if feature == FeatureName.VolumeUp:
if feature_name in _FIELD_FEATURES:
return FeatureInfo(state=self._is_available(_FIELD_FEATURES[feature_name]))
if feature_name == FeatureName.VolumeUp:
return FeatureInfo(state=self._is_available(("cmst", "cavc"), True))
if feature == FeatureName.VolumeDown:
if feature_name == FeatureName.VolumeDown:
return FeatureInfo(state=self._is_available(("cmst", "cavc"), True))
if feature == FeatureName.PlayUrl:
if feature_name == FeatureName.PlayUrl:
if self.config.get_service(Protocol.AirPlay) is not None:
return FeatureInfo(state=FeatureState.Available)

Expand Down
1 change: 0 additions & 1 deletion pyatv/dmap/tag_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def _read_unknown(data, start, length):


# These are the tags that we know about so far
# pylint: disable=bad-whitespace
_TAGS = {
"aeFP": DmapTag(read_uint, "com.apple.itunes.req-fplay"),
"aeSV": DmapTag(read_uint, "com.apple.itunes.music-sharing-version"),
Expand Down
19 changes: 10 additions & 9 deletions pyatv/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ async def finish(self) -> None:
raise exceptions.NotSupportedError()


class RemoteControl(ABC): # pylint: disable=too-many-public-methods
class RemoteControl(ABC):
"""Base class for API used to control an Apple TV."""

# pylint: disable=invalid-name
Expand Down Expand Up @@ -430,7 +430,7 @@ def __init__(
position: Optional[int] = None,
shuffle: Optional[const.ShuffleState] = None,
repeat: Optional[const.RepeatState] = None,
hash: Optional[str] = None,
hash: Optional[str] = None, # pylint: disable=redefined-builtin
) -> None:
"""Initialize a new Playing instance."""
self._media_type = media_type
Expand Down Expand Up @@ -663,6 +663,7 @@ class PushUpdater(ABC, StateProducer):

def __init__(self, loop: asyncio.AbstractEventLoop):
"""Initialize a new PushUpdater."""
super().__init__()
self.loop = loop
self._previous_state: Optional[Playing] = None

Expand Down Expand Up @@ -769,7 +770,7 @@ def __init__(
build_number: Optional[str],
model: const.DeviceModel,
mac: Optional[str],
) -> None: # pylint: disable=too-many-arguments # noqa
) -> None:
"""Initialize a new DeviceInfo instance."""
self._os = os
self._version = version
Expand Down Expand Up @@ -830,17 +831,17 @@ class Features(ABC):
"""Base class for supported feature functionality."""

@abstractmethod
def get_feature(self, feature: FeatureName) -> FeatureInfo:
def get_feature(self, feature_name: FeatureName) -> FeatureInfo:
"""Return current state of a feature."""
raise NotImplementedError()

def all_features(self, include_unsupported=False) -> Dict[FeatureName, FeatureInfo]:
"""Return state of all features."""
features = {} # type: Dict[FeatureName, FeatureInfo]
for name in FeatureName:
feature = self.get_feature(name)
if feature.state != FeatureState.Unsupported or include_unsupported:
features[name] = feature
info = self.get_feature(name)
if info.state != FeatureState.Unsupported or include_unsupported:
features[name] = info
return features

def in_state(
Expand All @@ -855,9 +856,9 @@ def in_state(
in one of the listed states.
"""
for name in feature_names:
feature = self.get_feature(name)
info = self.get_feature(name)
expected_states = states if isinstance(states, list) else [states]
if feature.state not in expected_states:
if info.state not in expected_states:
return False
return True

Expand Down
Loading

0 comments on commit 1e1922e

Please sign in to comment.