Skip to content

Commit

Permalink
cq: Run black to fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
postlund committed Jun 21, 2024
1 parent 2b0cc6a commit 1fc1cb0
Show file tree
Hide file tree
Showing 89 changed files with 127 additions and 38 deletions.
1 change: 1 addition & 0 deletions examples/manual_connect.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Simple example that shows how to manually connect to an Apple TV."""

import asyncio

from pyatv import conf, connect
Expand Down
1 change: 1 addition & 0 deletions examples/tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Comments has been added here to make linters happy.
"""

import asyncio

from aiohttp import WSMsgType, web
Expand Down
1 change: 1 addition & 0 deletions pyatv/auth/hap_channel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base class for HAP based channels (connections)."""

from abc import ABC, abstractmethod
import asyncio
import logging
Expand Down
1 change: 1 addition & 0 deletions pyatv/auth/hap_pairing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Abstraction for authentication based on HAP/SRP."""

from abc import ABC, abstractmethod
import binascii
from enum import Enum, auto
Expand Down
1 change: 1 addition & 0 deletions pyatv/auth/hap_tlv8.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Note that this implementation only supports one level of value, i.e. no dicts
in dicts.
"""

# pylint: disable=invalid-name

from enum import IntEnum
Expand Down
1 change: 1 addition & 0 deletions pyatv/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
possible to manually create a configuration, but generally scanning for devices will
provide configurations for you.
"""

from copy import deepcopy
from ipaddress import IPv4Address
from typing import Dict, List, Mapping, Optional
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
1 change: 1 addition & 0 deletions pyatv/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Core module of pyatv."""

import asyncio
from enum import Enum
from typing import (
Expand Down
1 change: 1 addition & 0 deletions pyatv/core/facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
NB: Typing in this file suffers much from:
https://github.com/python/mypy/issues/5374
"""

import asyncio
import io
import logging
Expand Down
1 change: 1 addition & 0 deletions pyatv/core/mdns.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Minimalistic DNS-SD implementation."""

import asyncio
from ipaddress import IPv4Address, ip_address
import logging
Expand Down
1 change: 1 addition & 0 deletions pyatv/core/protocol.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Generic functions for protocol logic."""

import asyncio
import inspect
import logging
Expand Down
1 change: 1 addition & 0 deletions pyatv/core/relayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
relayer.register(AirPlayMetadata())
artwork = await relayer.relay("artwork")(width=640)
"""

from itertools import chain
from typing import Dict, Generic, List, Optional, Sequence, Type, TypeVar

Expand Down
1 change: 1 addition & 0 deletions pyatv/protocols/airplay/ap2_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
however to set up a connection to an AirPlay 2 receiver and ensure encryption and
most low-level stuff is taken care of.
"""

import asyncio
import logging
from random import randint
Expand Down
1 change: 1 addition & 0 deletions pyatv/protocols/airplay/auth/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pick authentication type based on device support."""

import logging
from typing import Tuple

Expand Down
1 change: 1 addition & 0 deletions pyatv/protocols/airplay/auth/hap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""API for performing and verifying device authentication."""

from copy import copy
import logging
from typing import Any, Dict, Optional, Tuple
Expand Down
1 change: 1 addition & 0 deletions pyatv/protocols/airplay/auth/hap_transient.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
makes it easier to implement as the verification procedure step instead, so that's
how it works and why there's no setup procedure at all.
"""

import binascii
from copy import copy
import logging
Expand Down
1 change: 1 addition & 0 deletions pyatv/protocols/airplay/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module only deals with AirPlay 2 related channels right now.
"""

from abc import ABC
import logging
from random import randrange
Expand Down
1 change: 1 addition & 0 deletions pyatv/protocols/airplay/mrp_connection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""MRP connection implemented as a channel/stream over AirPlay."""

import logging
from typing import Optional

Expand Down
9 changes: 6 additions & 3 deletions pyatv/protocols/airplay/pairing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Device pairing and derivation of encryption keys."""

import logging
from typing import Optional

Expand Down Expand Up @@ -47,9 +48,11 @@ async def begin(self) -> None:
"""Start pairing process."""
self.http = await http_connect(self.address, self.service.port)
self.pairing_procedure = pair_setup(
AuthenticationType.HAP
if self.airplay_version == AirPlayMajorVersion.AirPlayV2
else AuthenticationType.Legacy,
(
AuthenticationType.HAP
if self.airplay_version == AirPlayMajorVersion.AirPlayV2
else AuthenticationType.Legacy
),
self.http,
)
self._has_paired = False
Expand Down
1 change: 1 addition & 0 deletions pyatv/protocols/airplay/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Manage announced AirPlay features."""

from enum import Enum, IntFlag, auto
import logging
import math
Expand Down
1 change: 1 addition & 0 deletions pyatv/protocols/companion/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""High level implementation of Companion API."""

import asyncio
from enum import Enum
import logging
Expand Down
1 change: 1 addition & 0 deletions pyatv/protocols/companion/auth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Device pairing and derivation of encryption keys."""

import logging
from typing import Dict, Optional, Tuple

Expand Down
1 change: 1 addition & 0 deletions pyatv/protocols/companion/connection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Connection abstraction for Companion protocol."""

from abc import ABC
import asyncio
from collections import deque
Expand Down
1 change: 1 addition & 0 deletions pyatv/protocols/companion/keyed_archiver.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Support for working with NSKeyedArchiver serialized data."""

import plistlib
from typing import Any, List, Optional, Tuple

Expand Down
1 change: 1 addition & 0 deletions pyatv/protocols/companion/pairing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Device pairing and derivation of encryption keys."""

import logging
from typing import Optional

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
In the absence of a robust NSKeyedArchiver implementation, these are pre-
encoded.
"""

import plistlib

__ALL__ = ["get_rti_clear_text_payload", "get_rti_input_text_payload"]
Expand Down
5 changes: 2 additions & 3 deletions pyatv/protocols/companion/protocol.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of the Companion protocol."""

from abc import ABC
from enum import Enum
import logging
Expand Down Expand Up @@ -85,9 +86,7 @@ def __init__(
self.connection.set_listener(self)
self.srp = srp
self.service = service
self._xid: int = randint(
0, 2**16
) # Don't know range here, just use something
self._xid: int = randint(0, 2**16) # Don't know range here, just use something
self._queues: Dict[FrameIdType, SharedData[Any]] = {}
self._chacha = None
self._is_started = False
Expand Down
1 change: 1 addition & 0 deletions pyatv/protocols/raop/audio_source.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Audio sources that can provide raw PCM frames that pyatv can stream."""

from abc import ABC, abstractmethod
import array
import asyncio
Expand Down
1 change: 1 addition & 0 deletions pyatv/protocols/raop/packets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Packet formats used by RAOP."""

from pyatv.support.packet import defpacket

RtpHeader = defpacket("RtpHeader", proto="B", type="B", seqno="H")
Expand Down
1 change: 1 addition & 0 deletions pyatv/protocols/raop/protocols/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base classes used by streaming protocols."""

from abc import ABC, abstractmethod
import asyncio
import logging
Expand Down
1 change: 1 addition & 0 deletions pyatv/protocols/raop/protocols/airplayv1.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of AirPlay v1 protocol logic."""

import asyncio
import logging
import plistlib
Expand Down
1 change: 1 addition & 0 deletions pyatv/protocols/raop/protocols/airplayv2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of AirPlay v2 protocol logic."""

import asyncio
import logging
import plistlib
Expand Down
1 change: 1 addition & 0 deletions pyatv/protocols/raop/stream_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
The client uses an underlying "protocol" for protocol specific bits, i.e. to support
AirPlay v1 and/or v2. This is mainly for code reuse purposes.
"""

from abc import ABC, abstractmethod
import asyncio
import logging
Expand Down
22 changes: 11 additions & 11 deletions pyatv/scripts/atvproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,10 @@ def process_outgoing_data(self, frame_type: FrameType, data: Dict[str, Any]):
"audio-session-coordination.system-info"
]
if "mediaRemoteGroupIdentifier" in audio_system_info:
audio_system_info[
"mediaRemoteGroupIdentifier"
] = shift_hex_identifier(
audio_system_info["mediaRemoteGroupIdentifier"]
audio_system_info["mediaRemoteGroupIdentifier"] = (
shift_hex_identifier(
audio_system_info["mediaRemoteGroupIdentifier"]
)
)

def process_incoming_data(self, frame_type: FrameType, data: Dict[str, Any]):
Expand Down Expand Up @@ -448,15 +448,15 @@ def process_incoming_data(self, frame_type: FrameType, data: Dict[str, Any]):
"audio-session-coordination.system-info"
]
if "mediaRemoteGroupIdentifier" in audio_system_info:
audio_system_info[
"mediaRemoteGroupIdentifier"
] = shift_hex_identifier(
audio_system_info["mediaRemoteGroupIdentifier"]
audio_system_info["mediaRemoteGroupIdentifier"] = (
shift_hex_identifier(
audio_system_info["mediaRemoteGroupIdentifier"]
)
)
if "mediaRemoteRouteIdentifier" in audio_system_info:
audio_system_info[
"mediaRemoteRouteIdentifier"
] = SERVER_IDENTIFIER
audio_system_info["mediaRemoteRouteIdentifier"] = (
SERVER_IDENTIFIER
)


class AirPlayChannelAppleTVProxy(AbstractHAPChannel):
Expand Down
6 changes: 3 additions & 3 deletions pyatv/scripts/atvremote.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,9 +702,9 @@ async def cli_handler(loop): # pylint: disable=too-many-statements,too-many-bra

if args.mdns_debug:
# logging.TRAFFIC is set in runtime by support.mdns
logging.getLogger(
"pyatv.core.mdns"
).level = logging.TRAFFIC # pylint: disable=no-member
logging.getLogger("pyatv.core.mdns").level = (
logging.TRAFFIC # pylint: disable=no-member
)

cmds = retrieve_commands(GlobalCommands)

Expand Down
8 changes: 5 additions & 3 deletions pyatv/scripts/atvscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,11 @@ async def _run_command(atv, args, abort_sem, loop):
if args.command == "playing":
return output_playing(
await atv.metadata.playing(),
atv.metadata.app
if atv.features.in_state(FeatureState.Available, FeatureName.App)
else None,
(
atv.metadata.app
if atv.features.in_state(FeatureState.Available, FeatureName.App)
else None
),
)

if args.command == "push_updates":
Expand Down
1 change: 1 addition & 0 deletions pyatv/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Settings for configuring pyatv."""

from enum import Enum
import re
from typing import Optional
Expand Down
1 change: 1 addition & 0 deletions pyatv/storage/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Storage module."""

from hashlib import sha256
from typing import List, Sequence

Expand Down
1 change: 1 addition & 0 deletions pyatv/storage/file_storage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""File based storage module."""

import asyncio
import json
import logging
Expand Down
1 change: 1 addition & 0 deletions pyatv/storage/memory_storage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Memory storage module."""

from pyatv.storage import AbstractStorage

__pdoc_dev_page__ = "/development/storage"
Expand Down
1 change: 1 addition & 0 deletions pyatv/support/buffer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Classes and functions for data buffering."""

from typing import Union

from pyatv.exceptions import InvalidStateError
Expand Down
1 change: 1 addition & 0 deletions pyatv/support/chacha20.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Transparent encryption layer using Chacha20_Poly1305."""

from functools import partial
from struct import Struct
from typing import Optional
Expand Down
1 change: 1 addition & 0 deletions pyatv/support/collections.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Collections for pyatv."""

import asyncio
import collections.abc
import typing
Expand Down
1 change: 1 addition & 0 deletions pyatv/support/dns.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Processing functions for raw DNS messages."""

import collections.abc
import enum
import io
Expand Down
1 change: 1 addition & 0 deletions pyatv/support/http.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module for working with HTTP requests."""

from abc import ABC, abstractmethod
import asyncio
from collections import deque
Expand Down
1 change: 1 addition & 0 deletions pyatv/support/metadata.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Convenience methods for extracting metadata from an audio file."""

import asyncio
import io
from typing import Union
Expand Down
1 change: 1 addition & 0 deletions pyatv/support/opack.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Pack implementation does not implement UID referencing
* Likely other cases missing
"""

from datetime import datetime

# pylint: disable=too-many-branches,too-many-return-statements,too-many-statements
Expand Down
1 change: 1 addition & 0 deletions pyatv/support/packet.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Generic utility for encoding and decoding binary packets."""

from collections import namedtuple
import struct

Expand Down
1 change: 1 addition & 0 deletions pyatv/support/rtsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This is a simple implementation of the RTSP protocol used by Apple (with its quirks
and all). It is somewhat generalized to support both AirPlay 1 and 2.
"""

import asyncio
from hashlib import md5
import logging
Expand Down
1 change: 1 addition & 0 deletions pyatv/support/shield.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def guarded(self):
```
"""

from functools import wraps
from typing import TypeVar

Expand Down
Loading

0 comments on commit 1fc1cb0

Please sign in to comment.